Hi dear Twine fellows
I am having some hard time at the moment trying to implement a save/load mechanism for my Twine project.
I am using Twine 1.4 and Jonah.
My project (described in this post
) simulates a mobile text conversation between the player and a girl named 'Cat'.
Jonah format does a great job here by keeping all previous passages/dialogs displayed on the page while the player progress through the game.
Saving the history is not really a problem here, since we can access to the History object from Twine.
But the reload part is more complex : I would need the entire dialog history to be re-displayed so that the player don't loose anything and can still go back to a previous passage to make another choice.
I've tried a quick and dirty hack where I saved the part of the DOM where passages are displayed and then re-inject it at startup. It kind of works, all previous passages are properly displayed but the event handlers are now detached, meaning that links won't work anymore.
I thought I could try to re-attach them using .on jQuery function but I would prefer having a cleaner solution since I'd probably still encounter other issues.
Then I had a try using the bookmark used by Twine in the save/encode+restore/decode functions. Here, when restoring I would display all passages from the decoded history instead of the last one only. Again, this almost works but it means the whole history is being re-played and this is an issue for some macros such as <<either>> which lead to some inconsistencies.
As a side note : so far I used localStorage to save whatever needed to be saved but it doesn't seem that persistent (there are some bugs) and mobile OS could decide to wipe it off in case of memory shortage.
So I will probably have to use some Cordova plugin to store those save data safely, on mobile at least.
Here is where I stand, did anyone already try to achieve this kind of stuff? Any thoughts/advices?