Howdy, Stranger!

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

Exporting and Loading Save Files In Snowman 1.3?

I'm sure there's a way to do it, but for the life of me, I can't figure it out. Has anyone already written anything that supports either multiple saves or loading from a file for Snowman 1.3?

Comments

  • Snowman does not have a built-in feature for saving (or loading) the Reader's progress to/from file.
    It can save that progress to the web-browser's local storage, although based on information on the Snowman 2 project overview it appears that the Reader's progress is not automatically tracked.
    By default, clicking a passage link does not add an entry to the reader's browser history. See story.checkpoint() for how to do this.
  • Right. Where would I start if I wanted to write my own save/load feature? I already have a set-up for tracking the progress.

    I also would like to be able to remember a variable across playthroughs and saves, similar to SugarCube's <<remember>> macro. Would that be possible? I'm new to Javascript, so I'm not sure where to start.
  • This unfortunately may take some work, and I'm not sure there's one correct answer as there are lots of different approaches you could take.

    Here are some clues on your journey!
    • window.story.state contains your variables, and window.story.history is an array of passage IDs the reader has visited, in order. IDs are internal numbers -- not the names you typed into the editor.
    • You can turn a complex JavaScript object into a string representation by calling JSON.stringify() on it, e.g. JSON.stringify(window.state).
    • You can turn that string back into an object by calling JSON.parse() on it, e.g. JSON.parse(JSON.stringify(window.state)) will give you window.state right back.
    • You can permanently store strings in a reader's browser by using local storage. Here's a pretty accessible introduction to using local storage.
Sign In or Register to comment.