Manual saving - how best to accomplish?

I have disabled automatic saving in Squiffy by commenting our the various calls to the save function in the main Squiffy template.

I'd like to manually call the save function at specific points in my story, but I'm running into the following problem.

Whilst I can call the save function using...;

It doesn't really work because (I think) my command is executed before the new section text is loaded, meaning that the previous passage is saved instead, with all links disabled.

Now as I see it I have two options, one of which I'm not sure will work.

Option one: Try and delay the calling of the save function using setTimeout

setTimeout(function() {; }, 1000);

I'm wondering whether this might solve the issue of calling the save function before the new section text has been loaded? I haven't been able to try it yet but I have my suspicions this might not work.

Option two: Get down and dirty with the main Squiffy template file, and add some conditional logic to the save function so it only triggers when certain conditions are met - a simple boolean variable would suffice. That way I can set the variable to on for the passages where I want Squiffy to save.

Any other suggestions?

Option one seems to have worked. It's actually a good workaround generally to execute Javascript post-section load.

Hmmm, this sort of works, but there remains an issue. I thought the save function dealt with saving in it's entirety, but looking at the code it only appears to deal with passage text. Attributes are saved separately, seemingly after each modification. So a real danger that things could become out of sync.

Further modifications needed.

So I think I've worked out a solution. A re-write of the core Squiffy functions would be too time consuming but this is a reasonable workaround.

I'm not going to go into too much detail as I appreciate very few people will be interested. But in a nutshell I'm doing the following:

Since I'm saving section progress at specific points, I need a way of capturing all my attribute states at the same time and writing them to memory. As ordinarily they would be overwritten by any subsequent attribute changes, I need to create a duplicate set that will automatically be reloaded if the user resumes from the checkpoint.

This should be pretty easy to do. Will report if it works or not.

This topic is now closed. Topics are closed after 60 days of inactivity.