How to Save, in Codea

I an currently working on a project that has a score(increases every time I pick up an object). I would like to be able to save that score so every time I open up the app my score stays the same and I don’t have to start over completely.

Check out the codea reference for:




basically its:

local score = 100

readScore = readProjectData("Saved_Score")

Also there are some tricks with the type of what you save: numbers turn into strings or so. It is a bit of a headache at the beginning.

This works:
for saving i use global data, to keep the score even if i change the project name (or version). Tostring() makes sure i contol the type


When reading, i have to convert back to number

score = tonumber(readGlobalData("thisGameScore")) or 0

Thanks, that really helped! My game is going to be much better now!