Howdy, Stranger!

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

Keeping Track of Points

I'm using Sugarcube and I'm trying to do a story with some questions mixed in it with answers. Each answer is worth different points and takes you to different points of the story. They are all normal links, and I am trying to work out either clicking on the link or when you visit the page the link takes you will assign you a some points. Then when you reach the end it keep tracks of all the points and show you. Not entirely sure how to go about doing this as a new twine user. Any help or point in the right direction will be much appreciated!

Comments

  • You should always mention which version of the Story Format you're using.

    Anyway, it seems like all you really need is some variables and some settler links.

    Create a new passage called StoryInit and put something like this in it:
    <<set $score to 0>>
    

    This is called initializing a variable. We create a variable, which is a word (called an identifier), with a $ (called a sigil). The StoryInit special passage is specially designed for Twine authors to initialize their variables. It's a good practice to initialize all your variables before using them.

    To use a setter link, you add a little bit of extra code to your normal links:
    [[link text|passage name][$score += 10]]
    

    When the settler link is clicked, the variable will be changed.
    $score += 10
    

    is shorthand for
    $score = $score + 10
    

    which would also work and have the same effect.

    When you're ready to test the score, you can use an <<if>> macro:
    Your score is $score. 
    
    <<if $score gte 100>>\
    You're amazing. 
    <<elseif $score lte 20>>\
    You suck. 
    <<else>>\
    You did okay, I guess. 
    <</if>>
    
  • Thanks! Didn't realise I needed to make a StoryInit passage. Taking time to get used to all this.
  • Chapel wrote: »
    To use a setter link, you add a little bit of extra code to your normal links:
    [[link text|passage name][$score += 10]]
    

    I needed these settler links, didn't know they existed.... Maybe it should be mentioned on http://twinery.org/wiki/twine2:how_to_create_links ?

  • Chapel wrote: »
    To use a setter link, you add a little bit of extra code to your normal links:
    [[link text|passage name][$score += 10]]
    

    I needed these settler links, didn't know they existed.... Maybe it should be mentioned on http://twinery.org/wiki/twine2:how_to_create_links ?

    It is mentioned right in the next section.
  • I needed these settler links, didn't know they existed.... Maybe it should be mentioned on http://twinery.org/wiki/twine2:how_to_create_links ?
    Each story format has it's own method for implementing Setter Links, currently the Twine (1 and 2) Wikis are mostly meant as a general guild to the product. For information related to a specific story format you should really read their own documentation.

    As you are using SugarCube (1.x or 2.x ??) reading either the 1.x Markup Links section or the 2.x Markup Links section would of shown you how to do what you wanted.

    idling wrote: »
    It is mentioned right in the next section.
    That documentation is for the Twine 1.x application and is actually targeting the 'vanilia' story formats (Sugarcane, Johan, and Responsive) that came pre-installed with that product, although some information in that part of the Wiki can be used in conjunction with SugarCube.
Sign In or Register to comment.