Log In  

Imagine this folder structure

├── libs
│   ├── b.p8
│   └── c.p8
└── main.p8

If main.p8 calls ./libs/b.p8 which in turns wants to call c.p8, it has to use use the relative path from the main cart, i.e. ./libs/c.p8 even if b.p8 and c.p8 is in the same folder.

Usually programming languages have relative paths starting from the file that is doing the import. Could we get the same behaviour for pico-8 please?

Right now most multi-cart games have everything in single dir which makes things looking pretty messy, and if I want to have a multi cart game on my rgb30 where I hide the extra files in .hidden I have to edit all files making load calls to make things work which is not optimal.

Here is full code to replicate (files created with vs code, hence the extra stuff at the top):

What works:

Filename: main-absolute.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In main-absolute.p8")
load("libs/sub-load-with-absolute-path.p8")

Filename: libs/sub-load-with-absolute-path.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In sub-load-with-absolute-path.p8")
load("libs/final-destination.p8")

Filename: libs/final-destination.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In final-destination.p8")

What I would like to work

Filename: main-relative.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In main-relative.p8")
load("libs/sub-load-with-relative-path.p8")

Filename: libs/sub-load-with-relative-path.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In sub-load-with-relative-path.p8")
load("final-destination.p8")

Note the missing libs/ in the load 👆

Filename: libs/final-destination.p8

pico-8 cartridge // http://www.pico-8.com
version 41
__lua__

print("In final-destination.p8")

Ive yet to see any multi cart games using any type of folder structure, so in theory should be safe to implement.

Thoughts?

P#141209 2024-02-06 17:16 ( Edited 2024-02-10 15:50)

1

I would agree with this 100%. Includes should be relative to the file they're included from. I didn't even know it was like this, so I guess I never tried to do it, else I would have complained about it myself.

P#141366 2024-02-10 15:16

[Please log in to post a comment]