0 votes
by (550 points)

Hi! I hadn't noticed that story.checkpoint() is both:

  1. the method that fills the browser history (enabling back and forward buttons)
  2. and the method that keeps the story status in localStorage or whatever, so if you load the page again, you can access that status for continuing the game
My problem is: I want 2, of course, if you need to stop playing you should be able to continue. But out of creative reasons, I don't want 1. I don't want the player to go back and try a different choice (unless they restart from the beginning). I want a single savegame without browser history.
So I'm wondering how can I do this. Can I use story.checkpoint() but somehow disable the back button without breaking the function? Should I do something ad hoc like the function in this answer? (I would need to change that function so loading the savegame isn't automatic, but done on click).
I'm very lost on this, due to my extremely limited JS. Can you help? Thanks!

1 Answer

0 votes
by (68.6k points)
selected by
Best answer

The story. checkpoint() method only sets up new browser history entries to be created.  It has nothing to do with any kind of storage, so you've misunderstood something.  Thus, if you don't want browser history entries to be created, then don't use the story. checkpoint() method.

As far as saves go, which Snowman does not natively offer, you might want to have a look at the Saving Games cookbook entry for Snowman, which allows you to manually save.  The answer from the other question you linked also works, but is more for automatic saves.


PS: If you have "extremely limited JS [skills]", then you've chosen your story format poorly as Snowman is, literally, the "you had better know JavaScript" story format.

by (550 points)

Aw crap.

You're totally right. I must have been very sleepy yesterday when I disabled story.checkpoint and believed that the savegame stopped working. I did it again and yeah, it's totally unrelated.

So I looked again and found the actual code for my autosave. Guess I really need to comment my code better.

My JS is limited but Snowman is my only option (my Harlowe design killed any mobile) and I'm kinda getting through it with the awesome help from this forum.

So sorry, and thanks!

PS: for the record, this is my autosave code:

localStorage.setItem( 'autosave', JSON.stringify( story.state ));