cartdata( id )

Sets up cartridge data for the cart.

A string that is likely to be unique across all Pico-8 carts.

A cartridge can store 64 numbers (256 bytes) of data to persistent storage. This data is available the next time the user runs the cart, and persists in the player even if the cartridge is replaced with a new version of the same cartridge.

The cartdata() function sets up Pico-8's persistent cartridge data feature. It must be called once (and only once) by the cart before using dset() or dget().

The function takes a string ID that uniquely identifies the cartridge among all Pico-8 cartridges that might have persistent data. There is no central registry for cartdata IDs, and you're expected to not willfully overwrite data belonging to other carts. Likewise, you can purposefully use the same ID across multiple carts to share persistent data between carts, such as to implement a very large adventure game that requires multiple carts.

One reasonable way to derive a unique ID for your cart is to use the following pattern:


... where username is your Pico-8 BBS username, title is the title of the cartridge, and version is an optional version ID. You would only increment the version ID if a new version of the cart stores cart data in a format incompatible with previous versions.

Once cartdata() has been called, the data bytes can be accessed directly at memory locations 0x5e00 to 0x5eff. Using poke() to update these values persists the new value automatically, similar to dset().

Examples Edit

function _init()
  player_pos = dget(0)
  player_inventory = dget(1)

function save_game()
  dset(0, player_pos)
  dset(1, player_inventory)

See also Edit

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.