Howdy, Stranger!

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

Is there a way to make a command in a passage to quit the game?

Hi, I am trying to create my own story using Twine, and would like to provide my users with an option to terminate the game (this is because i am attempting to do this for a school project that has that requirement), yet i am not very well versed in the types of coding that Twine uses. If anyone could instruct me as to where i can find the proper information, as a couple hours scouring the internet did nothing for me, or if you could simply just provide me with the coding (for which i will gladly give you credit for your contribution), it would help me out a lot. Thanks in advance.

Comments

  • You didn't say what story format you're using, assuming you chose one already, but SugarCube 2 has a Restart button in the sidebar, always shown by default. That's about the closest you can get, since there's no real way for a web page to close itself. Well, unless it was opened in its own window from the beginning, but you have to arrange for that specifically. You can do that in Javascript with the window.open function; once the game was opened that way, this code should show a link that closes it when clicked:
    <<link "Quit game">><<script>>window.close()<</script>><</link>>
    

    Again, this is for SugarCube 2 specifically, and untested. Hope it helps anyway.
  • Assuming that you want to close the window/tab, as felixp7 surmised, here's how you could do it in some of the story formats commonly available for Twine 2. felixp7 already covered SugarCube v2, but I'll cover it again for the sake of completeness.

    Harlowe
    (link: "Quit")[<script>window.close()</script>]
    
    Snowman
    <a href="javascript:window.close()">Quit</a>
    
    SugarCube v2
    <<link "Quit">><<script>>window.close()<</script>><</link>>
    
    SugarCube v1
    <<click "Quit">><<script>>window.close()<</script>><</click>>
    
  • Thank you for your answers, extremely helpful to someone just starting out. Exactly what i was looking for, and i wasn't exactly sure what story format i was using, as i was literally just writing stuff and not really worrying about any code (other than links, and im not sure what format it is) but thank you fro the help.
  • derslayr wrote: »
    and i wasn't exactly sure what story format i was using
    I suggest reading the Twine 2 Guide linked to from the Twine Wiki, which itself is linked to from the main Twine website.

    The How to Choose a Story Format section of the guide explains about Story Formats, which I believe is one of the more import decisions you need to make when starting to create a Twine based story/game.
Sign In or Register to comment.