For my WIP (SugarCube v0.9.9), I need to be able to wipe the user's locally stored saves and options when I post a new version of the Twine HTML file. My thought is that I would store the version as a property in the options object and check on startup to see whether it has changed; if it has, wipe the existing data stores.
I'm wondering:
1) StoryInit seems like the best place to do this. Is there any reason to think otherwise?
2) Is there already a version number present somewhere in the HTML file that I could use for this purpose, or will I need to manually version it? The IFDB doesn't list IFIDs for Twine files, and there also doesn't seem to be a version of any sort in the Twine HTML file.
3) Are these indeed the best ways to wipe the save and option stores?
SaveSystem.purge();
<<deleteoptions>>
Thanks for any help!
Comments
[list type=decimal]
There's not much point in waiting for
StoryInit
to be run, that's pretty deep down the rabbit hole. Ideally, I think that you'd want to do this as soon as you could.Twine/Twee do not version the compiled HTML, so you would need to do it manually.
Those would work, yes.
And, I can't say that I'd recommend storing your version in options.
For the moment, I'd suggest something like this:
storage
is an instance of SugarCube's key/value storage API. In particular, it's used for persistent storage (there's a separate instance for temporary per-session storage). And yes, currently, persistent storage is handled bylocalStorage
, if functional. I plan to supportindexedDB
in the future as well, but I'm going to wait until it's a TR, at least.