Skip to content
Kyuchumimo edited this page Oct 29, 2021 · 13 revisions

pmem

🧩 This function depends on os Python 3.x built-in module.
🧩 This function depends on sys Python 3.x built-in module.
🧩 This function depends on json Python 3.x built-in module.

pmem index -> val Retrieve data from persistent memory file

pmem index val -> val Save data to persistent memory file

Parameters

  • index : an index (0..255) into the persistent memory file.
  • val : the value you want to store. Omit this parameter to read vs write.

Output

val : when the function is call with only an index parameter, it returns the current value saved in that memory slot.

Description

This function allows you to save and retrieve data in one of the 256 individual 32-bit slots available in the cartridge's persistent memory. This is useful for saving high-scores, level advancement or achievements. Data is stored as unsigned 32-bit integers (from 0 to 4294967295).

Example

#####################################

#pmem demo
#load saved value at slot zero and save it back
#incremented by 1
pmem(0,pmem(0)+1)

while True:
    cls()
    print("Started {} times".format(pmem(0)));

#####################################
Clone this wiki locally