Howdy, Stranger!

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

[Sugarcube] autosave/autoload interferes with restart

When autosave and autoload are turned on, restarting (via the sidebar Restart link) doesn't go back to the Start passage, but rather loads the autosave. Deleting the autosave slot and then restarting works as expected.

Sample code:
::Start
[[Next]]

::Next
Page 2

::config [script]
config.saves.autoload = true;
config.saves.autosave = true;
config.saves.isAllowed = function () {
return passage() != 'Start';
}
(the .isAllowed part doesn't seem to affect the behavior, but the docs recommended it so I included it for the sake of correctness)

Build with:
twee -t sugarcube test > /var/www/twine/test2.html
Steps to reproduce:
1. click Next
2. click Restart
3. page should display "Next" link, instead displays "Page 2" text

Comments

  • Using the Restart menu item reboots the game/story, nothing more or less.  Specifically, returning the player to the starting passage is not part of its functionality.  That said, the player would normally be returned to the starting passage upon using Restart, yes, but that's simply because that's the default action upon startup.  If, on the other hand, you configure SugarCube to automatically load an existing autosave upon startup, then that's going to take priority over going to the starting passage.

    If you don't like that behavior, you have a few options:

    1. Configure SugarCube to prompt the player about loading the autosave instead.  You can (as of v1.0.8) set the config.saves.autoload setting to "prompt", which will offer the player a choice about whether to load an existing autosave or not.

    2. Make deleting an existing autosave part of the Restart menu item's behavior by binding an additional handler to it.  For example:

    $("#menu-restart a").click(function () {
    if (SaveSystem.autosaveOK() && SaveSystem.hasAuto()) {
    SaveSystem.deleteAuto();
    }
    });
    There are other options, but those two are the easiest.

    PS: You're not terminating your function expression with a semi-colon, you should be.
  • Thank you!

    In my opinion that delete-on-restart behavior should be the default.
  • I disagree. I think the way that TME has it set up makes the most sense. You should never delete the user's data without asking.
Sign In or Register to comment.