I'm trying to add a "Restart" button to my game, but the problem is it doesn't work properly with my save system. I have
{
(save-game: "Save")
}
at the bottom of each passage to act as an autosave function, and my first passage is this
(if: (saved-games:) contains "Save")[
(load-game: "Save")
](else:)[
(goto: "Intro")
]
I also have a button in my header that contains this
{
(link: "Restart")[(confirm: "Are you sure?")[(goto: "Intro")]]
The problem is that all the values are still saved when restarting, and the links you previously clicked are purple. The only solution I can think of is to have a unique save file for the intro screen that the Restart link loads that contains no previous data. If there's an easier way to restart the game however, I'd much rather use that, since the load feels clumsy.
Comments
re: automatically returning to last passage viewed.
You may want to give the reader a yes/no choice before automatically using (load-game: "Save") to return the reader to the last passage they viewed or else the reader wont be able to replay your story/game from the start without either using your restart option or clearing their web-browser's cache.
Either way, I managed to fix the restart function using a bunch of save cheats.
This is at the bottom of my Intro page:
This is the code for the start-up screen:
This is the code for the restart button (which is always in my header):
Basically when you click restart, it loads the GameStart and then immediately saves over the Save file, and everything is working as intended. I haven't encountered any problems with this, even though it feels like a very clumsy way of doing it.
Thank you for your help anyway! I appreciate your answers as always, they're always very educating and enlightening.
The actual simplest way is to use the macro, for the record.