Can you record a variable that persists when the story restarts?

Note: I’m currently using Harlowe, but am at a very early stage of development with only passage links in use, so it would be very easy for me to switch to another story language if this can’t be done in Harlowe.

Basically, what I want to do is get Twine to record the state of a variable so that it persists forever, even if the player restarts the story from the beginning. This is so that I can keep track of which ‘Ending’ passages the player has already seen and offer them bonus content for finding all the possible endings, and possibly so that I can implement an ‘Achievements’ screen too.

Is there a way to accomplish this?

I do not know harlowe but this might help


Thanks, @sh221b777

This might do the trick, but it looks like Harlowe doesn’t support local storage ‘out of the box’ and I’m not keen on the proposed solution. It hints that SugarCube might support such a feature better, so I’ll investigate how Local Storage works in SugarCube and see if that would be better for my purposes.

In the meantime, I’m open to any other suggestions people might have!

I think I’ve been looking at the wrong documentation for Harlowe. It looks like I should be able to save the game automatically after each choice, and restore it automatically on startup. I can then implement an automatic ‘New Story+’ option on each end screen that simply leaps back to the start of the story with all variables intact. It just means I have to be careful to manually reset any variables that DO need to be reset at the beginning of the story.

1 Like

I have not used it, but SugarCube does have a functions built in to handle this.


On the whole, I think this is the better option. I’m not quite as fond of the default ‘look’ of SugarCube, but I’ve seen a lot of comments now saying Harlowe is a bit flaky, and I expect I can probably produce something better-looking when I start messing around with the game’s CSS.

1 Like