Local versus Project Storage

So - I’m not where I can easily test this, but I just read the Storage documentation.

The docs for local storage say “this device”, implying strongly that you could save something in local storage in one project, and read it in another, ie. it’s Codea-global. Is this actually the case? (If so - NEATO!)

I was initially scratching my head when i first saw the persistance api but it does have one interesting use. Level editors and turn based games. So you could potentially export a project with levels you made, saved directly into the project and others could share versions of that same project with new levels that they made. You could also make a game with a persistant saved data that you can share around for turn based games

No it’s project only, we thought about allowing cross-project references but that could easily cause data corruption and confusion for common names (e.g. “highscore”). We can add a saveGlobalData() that stores global device data, though.

I guess I don’t understand the difference then. If they’re both per-project, that simply means one goes out when you email/export the project, and the other does not?

Yes please on the global.

(Pity - I was thinking “global” storage might be a good place to keep, for example, a single instance of font data, or persistent preferences like name or such…)

Yes, global definitely has a use. I can’t see a reason not to add it. But you can think of local and project like this:

Local - retrieves a dictionary stored on the device with all your project’s values. So for example if I call readLocalData(“highscore”) in “MyProject” Codea will do the following:

  • Fetch “MyProject” data from the device
  • Load “highscore” from “MyProject” device data

Project - retrieves a dictionary stored in the project’s folder as a file. So readProjectData(“highscore”) in “MyProject” does the following:

  • Fetch MyProject.codea/Data.plist from the file system
  • Load “highscore” from this data file