Hey everyone, I was just wondering for a potential multicart project:
How would I pass data from one cart to another, mainly a base cart for things like high score or level unlocks?
Thanks in advance.



The most straightforward way is to use cartdata()
, dset()
and dget()
; so long as two carts share the same cartdata ID, they share the same storage space.
If you need more than 64 numbers or if you want to pass larger amounts of nonpersistent data, you can use peek()
and poke()
to write directly to general memory: the range between 0x8000 and 0xffff persists so long as PICO-8 is running, meaning anything you write there will be accessible by other carts that get loaded in during runtime.



Wow, that cartdata info is really straightforward, and the peek/poke combo is excellent.
Many thanks!



I believe you can pass a variable or function or something as a parameter in the LOAD() function? You put in the cart to load, then a breadcrumb that I believe will link back to the main cart, and then the third parameter will be passed as a spot in memory? (Can someone please double check this?)



Only strings can be passed with load().
Use stat(6) to receive the data in the destination cart.
Instead of passing a function, you can separate initialization functions etc. using conditional branching based on strings.
If you want to pass a lot of data, you will need to assemble a parseable string, such as one separated by commas.
As mentioned in the previous comment, if you are handling data larger than 1024 characters (1024 bytes), you will need to use poke/peek. (This is more non-volatile than load.)
[Please log in to post a comment]