Renaming a project resets the local data?

It seems renaming a project resets all the local data. Is that what we want?

1 Like

@piinthesky - could you explain that a little more.

Hmm that’s a good find. I’ll need to look into that some more, but I expect you’re better off using “project” data for this purpose

The idea of “local” data is data that is recorded in the system (ie. globally) against the project, but not stored with the project. Something like a high score in a game. This made more sense when Codea was self-contained, but now days a project can be renamed from anywhere — inside the Files app for example — and Codea may never know about it. And so it would lose the connection to the project’s local data

We may have to re-architect how this works to use a permanent random ID associated with the project on creation to key the local data against, rather than the project name

@sim i was using localData in my program. When running in the same window all works. When i run in new window, it crashes. It seems the readLocalData does not work, it return nil and does not even return the default value. When i changed to readProjectData it works fine in same window or new window.

@piinthesky I tried what you said about LocalData and I also get nil when it’s run in a new window. However, Codea didn’t crash when I tried it. One thing I noticed about LocalData that I posted years and years ago was if a project uses LocalData and you delete the project, the LocalData isn’t deleted. So if you delete a lot of projects that uses LocalData, it’s memory will still be allocated.

One way to check this is to create a project that savesLocalData, readlocaldata and then prints the value. Delete the project. Create the same project again with readlocaldata and print its value.

yes i was not precise…my code gave an error message due to the local data being nil. It should not be nil as if the data doesn’t exist it should take the value given by the second parameter.