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:
saveLocalData()
saveProjectData()
saveGlobalData()
http://twolivesleft.com/Codea/Reference/Storage.html#
basically its:
local score = 100
saveProjectData("Saved_Score",score)
readScore = readProjectData("Saved_Score")
print(readScore)
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
saveGlobalData("thisGameScore",tostring(score))
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!