Log In  

Is it possible to link multiple .p8 file together so that I can create a single level in one file and then save a few variables, then load the next .p8 file to create a second level?

P#26134 2016-07-30 10:56 ( Edited 2016-11-26 13:30)

reload() takes an optional filename that lets you load memory regions from other carts. Using just reload(), you can have all of your code in the main cart, then load level data from other carts. Cart ROM normally stores sprite, map, sfx, and music data, but you can store arbitrary bytes and move them around with memcpy() and the like if needed. http://pico-8.wikia.com/wiki/Reload

load() is actually just the "load" command that you can type at the command prompt, and it can be called from a cartridge. When called from a cart, it replaces the current cart in memory including code and temporary RAM and starts executing it immediately. http://pico-8.wikia.com/wiki/Load

load() does not allow you to preserve local variables, but you can use cartdata to persist values associated with a key that both carts share. You'd call cartdata() with the same key in both carts, then call dget() and dset() to get and set the values, respectively. http://pico-8.wikia.com/wiki/Cartdata

P#26192 2016-07-31 01:33 ( Edited 2016-07-31 05:34)

That's genius, I've been wondering if you can "link" carts together to make a sort of episodic game. I think reload() might work perfectly.

P#26201 2016-07-31 04:56 ( Edited 2016-07-31 08:56)

That is pretty interesting to think about. Although just using load() with save data means each cart would have to have the same "primary" code...essentially duplicating your code and maintenance, less than ideal.

I'd think the reload() stuff might lend itself more to the episodic idea but is probably more complicated to implement...? Either way, interesting to consider making a game that needs multiple carts - "Insert disk 2" hehe

P#26337 2016-08-02 14:00 ( Edited 2016-08-02 18:00)

How does this work in relation to SPLORE? Can you submit multi-cart games?

P#32766 2016-11-26 00:59 ( Edited 2016-11-26 05:59)

reload() doesn't work with BBS-loaded games. They must be local files.

A player could conceivably download each of the parts of a multipart game via Splore to the local filesystem, then start the main cart from Splore using the local files category. Currently, saving a cart this way requires exiting Splore while the cart is in memory to get to the command prompt, then using the save command. So it's not exactly user friendly. But technically you can do it without leaving Pico-8.

It'd be cool if reload() and related functions had BBS equivalents that you could call with BBS cart IDs, maybe as a fallback if the file is missing locally but there's an Internet connection. But this is not currently a feature.

P#32768 2016-11-26 03:11 ( Edited 2016-11-26 21:20)

why not have multi-bank carts instead ?

limited to 4 banks (128k), for limits' sake. plus, loading a bank brings up a 5 seconds loading screen with raster bars in the overscan zone. maybe even draw the label line by line.

that would bring a tear to my eye. :'-)

P#32771 2016-11-26 08:30 ( Edited 2016-11-26 13:34)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-03-28 10:04 | 0.012s | 2097k | Q:24