Skip to content
Kyuchumimo edited this page Mar 16, 2022 · 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 -> val32 Retrieve value from persistent memory file

pmem index val32 Save new value to persistent memory file

Parameters

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

Returns

  • val32 : the current value saved to the specified memory slot.

Description

This function allows you to save and retrieve data in one of 256 individual 32-bit slots available in the file'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 " + str(pmem(0)) + " times");

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