Hi All,
Previously I restarted a story in game by just linking to the start passage and in my start passage I had all my variables which then reset.
I was advised this was poor form and that variables should go in a special passage StoryInit, I've done that but now when I link to start to restart the story none of the variables reset so how am I supposed to do it?
Thanks
nowherecity24
Comments
<<script>>
state.restart();
<<endscript>>
I'm not sure how you'd do it in any of the other story formats but this might help.
The StoryInit special passage also exists in the non-SugarCube headers in later versions of Twine.
SugarCube:
Simply do the following wherever you want a Restart link: That will open the standard restart confirmation dialog.
Vanilla story formats:
I don't know of a simple way that doesn't involve some complications, so something a little more involved is in order. Where will you be putting this restart link (or links)?
Good to know. Haven't looked at the Vanilla headers in forever.
Speaking of the vanilla headers, couldn't you write a script passage set to prerender that calls the restart function the game's UI calls if a certain variable is set? I'm not sure that would actually work as I've only ever scripted for SugarCube but it's the only thing I can think of that would be relatively simple to implement.
It's important to know where the link(s) need to be first. Otherwise, a naive solution could end up doing something terrible like attaching multiple event handlers to the same element. However, yes, if the links are inside the passage display area, then you could use a
postrender
task to attach an event handler which would callInterface.restart()
.Anyway, that's why I asked above where nowherecity24 is putting these link(s).
Thanks for your replies
I'm using sugarcane format with a stylesheet that gives me a central story page and then a stats box to the left.
I find it easy to read and it copes well with how I set up my games (apart from one thing which I just discovered that I will ask for help in yet another post!)
I know lots of you use sugarcube but as it puts a menu to the left I don't have the ability to play with that.
In my game I link to restart from an endgame passage example You have reached an end game [[restart|start]]
From your posts is appears I may as well just put all the variable inits back in the start passage as that works.
Is there any benefit to using StoryInit in my case?
Thanks
nowherecity24
Okay. Format is Sugarcane and you're going to use this inside normal passages.
Try this: (goes in a
script
tagged passage) And then do the following wherever you want a Restart link: That will open the standard restart confirmation dialog.Of course you do. The code/CSS you're using simply was not written to natively support SugarCube.
(I'm not suggesting you switch to SugarCube. Use whichever format you prefer. I just wanted to point out that SugarCube isn't really less malleable, let's say, than the vanilla headers.)
Please do not do that. If you use the code I gave above, then putting your $variable initialization in
StoryInit
, where it belongs, costs you nothing, and you'll be doing the right thing.Simply linking back to the
Start
passage is the completely wrong way to restart a story/game. Yes, if you put your $variable initialization inStart
, then going back there will reinitialize the $variables, however, none of the rest of the story state will be reset. Players will be caught in a situation where some of the story state has been reset and some has not (largely, the history stack will never get reset). [b][i]I strongly suggest that you do not do that.[/b]