Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[SugarCube] When to call SaveSystem.loadAuto()?

On my Start page, I used to have some code to autodetect whether there is a saved game. If a saved game is present, it would ask the user to press one of two buttons: One to delete the save and start over, and the other to load the save.

I recently removed that code and instead had any saved game automatically load, using this code at the end of StoryInit:

if (SaveSystem.autosaveOK() && SaveSystem.hasAuto()) {
SaveSystem.loadAuto();
}
(Restarting is now handled via a button in the menu.)

This seems to work OK, except that all of the display code now runs twice for the active passage when the game is reloaded. In other words, if you close your browser window on Passage B, then load the file in a new window, the display code for Passage B will run twice, including PassageReady and PassageDone.

I'm not 100% sure that the new approach to handling loading the saved game is responsible, but it seems the most likely culprit. I don't quite understand it, though, unless passage display is something that must complete before the previously requested load event is fired.

So, my question: Should I be calling SaveSystem.loadAuto() earlier, e.g. from a [script] passage? Or do I really need to call it in response to user input, as I originally did?



Comments

  • Currently, you'll probably need to call it in response to user input, because, off-hand, I can't think of a way to auto-load a save that wouldn't cause this problem.

    The issue is that there's no way to terminate the initial/normal load sequence, which you would need to do if you're trying to auto-load a save.  Otherwise, the auto-load will happen and then the normal load sequence will either follow or resume (depending on when you initiated the auto-load), thus reloading the passage.

    I'll look into it.
  • Okay.  Just published a new release which should address this issue.  If it gives you any problems, let me know.
Sign In or Register to comment.