Howdy, Stranger!

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

Restart link

How can I make a link or button in a passage that acts like the Restart button, but without confirmation?


  • For a normal link, just have it link to the 'Start' passage. So if you wanted it to say Restart, you'd do this:

  • That is a link back to the Start passage, not a true Restart. If I used visited(), the visit counter will remain the same. From my testing Restarting will wipe out everything except <<remember>>ed variables, and that is what I want to do.
  • The problem with using [[Restart|Start]] is that it will not null your variables. In order to do that, the easiest way is probably to just copy the restart code from code.js in your Twine/targets/Sugarcane folder and remove the popup window.
    if(confirm("Are you sure you want to restart this story?"))
    Then call the code with a script. There might be an easier way, but Im new to Twine myself.

    EDIT: I looked around for a couple minutes on the web and found that variables are stored here:
    So it should be easy enough to do a for loop and null them all. I'm testing it out and I'll let you know if I get something that works.
  • Solution that appears to work, though you'll have to put it through testing.

    Created a macro.
    macros['wipeout'] = {
    handler: function(place, macroName, params, parser) {

    var i = 0;

    while( i < 99 ) {
    state.history[i] = 0;

    Call it with <<wipeout>> before you restart. Obviously this is assuming you have less than 99 variables.

  • For a quit/restart link in one of my twines, I ended up writing this:
    <a onclick="location.reload()" class="internalLink">RESTART</a>
    which reloads the entire page, wiping out all history variables and returning the reader to the Start passage. A little clunky, but it works.
  • A little clunky he says. Does it in one line without a macro. Even if it is basically an F5, I should have thought of that. This is why my code is going to be ugly as hell by the time I'm finished. xD
  • You can just do this using straight Twine code, you know:

    Technically "Start" can be any passage name at all, since it's ultimately ignored due to the restart().
Sign In or Register to comment.