Howdy, Stranger!

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

[Sugarcube] Text appears after a given time / Having to restart 3 times to finish the game.

Hello everyone,

I'm quite new to twine as I just began a few days ago, and I don't really know anything about code...Nevertheless, I would like to achieve two things, and I'd be truly grateful if anybody could help me with that :

- First I'd like to open a passage with a blank page, on which the text will display after a given time. I think there is something like a timedreplace macro in Harlowe, but I would like to know if I can do this on Sugarcube, and if so, how.

- Secondly, and this may be a little tougher to explain : I'd like the game to remember each time you died, so that after you restarted the game, say, three times, a new link will appear leading to the true end of the game.

I don't know if any of this is possible, but any help will be quite appreciated.

Have a nice day :)

Comments

  • To be clear I'm on Sugarcube 1.0.34 :)
  • A. re: the text will display after a given time

    The <<replacelink>> macro set available for download from the Downloads -> Add-ons section of the SugarCube 1 website includes a <<timedcontinue>> macro which can be used to achieve the effect you want.

    The instructions on how to install the macro set into your Story Project can be read in the README.html file, which is contained within the ZIP file you downloaded and extracted onto your hard-drive. Look at the Leon's Combined <<Replace>> Macro Set webpage for a complete list of the macros available within the macro set.

    Example of how to delete the showing of text for five seconds:
    <<timedcontinue 5s>>\
    You should see this text after five seconds, before that the passage should of been empty.
    

    B. re: remember each time you died

    You can use the <<remember>> macro to achieve the effect you want. The following example consists of three passages.

    1. The StoryInit passage:
    You need assign a default value to the variable which is done in the StoryInit special passage but because you want to remember the value across play through you need to this in a way that won't effect the remembering.

    The following tests to see if the variable has been define before, which is will have if the variable has been previously remembered.
    <<if ndef $deaths>>
    	<<set $deaths to 0>>
    <</if>>
    

    2. The Tracking Deaths passage:
    The passage(s) the Reader dies in needs to first increment the variable and then remember the new value.
    <<set $deaths += 1>><<remember $deaths>>\
    You died, use the "Restart" link in the side-bar to try again.
    

    3. The Start passage:
    [[Tracking Deaths]]
    Deaths: $deaths
    
    <<if $deaths gte 3>>
    Add the extra link you want to show if they died three times here...
    <</if>>
    
    <<if $deaths gt 0>>
    <<click "Forget the number of Deaths">>
    	<<forget $deaths>>
    <</click>>
    <</if>>
    
    The first <<if>> macro in the above is what you would use to test if you need to show your extra link, the second <<if>> macro needs some explaining.

    Because you are remembering the Reader's deaths across all restarts (including when they close their web-browser and reopen the story/game HTML file) there needs to be a way for them to reset the variable or they will never be able to start the story/game from scratch.
    The <<forget>> macro undefined the variable, which means that it will be assigned a default value in StoryInit again.
  • Hey ! Thank you so much, it works perfectly ! And thanks for taking the time to explain each step, it really helps.

    Bonne journée :)
Sign In or Register to comment.