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

  • edited June 2017
    You have to give both the full version number of twine and of sugarcube to receive a specific answer. I'll just assume that you are using the latest version of Sugarcube 2 and the latest version of Twine 2.
    It seems that you should generally take a little time to read one of the basic tutorials floating around, like this one.

    Other than that, this is a variable:
    $points
    

    this is how you set up a variable:
    <<set $points to 0>>
    

    or
    <<set $points = 0>>
    

    In this case it's a number, but it can also be a string:
    <<set $name to "Adam">>
    

    and a number of other things. Most of the time you'll want to put this kind of initial setup into the passage titled StoryInit

    This is how you add one to your points:
    <<set $points = $points + 1>>
    

    or
    <<set $points += 1>>
    

    This is a setter link:
    [[linkname|passagename][$points += 1]]
    
    It will be named "linkname" and send the player to "passagename", all while adding 1 to $points.



    Edit: I just saw @Chapel already gave pretty much the samed answer in the identical other question you posted.
  • Thanks for posting, not sure why theres 2 forms. I will check out that guide thanks!
  • You might want to set your points up in a JSON object:
    <<set $score to { A: 3, B:5, C:4 }>>
    

    Then on your link do:
    [[Answer A|Location A][$points to $points + $score['A'];$score['A'] to 0]]
    

    Why? Well if they get back to the question they won't be able to score points for it twice.

    You could even use:
    <<if $score['A'] neq 0>>[[Answer A|Location A][$points to $points + $score['A'];$score['A'] to 0]]<<endif>>
    

    ...to hide answers they've already given, but ensure there's always something they can pick.

    Code untested, but should be pretty close.
  • mykael wrote: »
    You might want to set your points up in a JSON object:
    <<set $score to { A: 3, B:5, C:4 }>>
    

    Then on your link do:
    [[Answer A|Location A][$points to $points + $score['A'];$score['A'] to 0]]
    

    Why? Well if they get back to the question they won't be able to score points for it twice.

    You could even use:
    <<if $score['A'] neq 0>>[[Answer A|Location A][$points to $points + $score['A'];$score['A'] to 0]]<<endif>>
    

    ...to hide answers they've already given, but ensure there's always something they can pick.

    Code untested, but should be pretty close.

    That all sounds a tad unnescessary. Why would you link the player back to already answered questions?
Sign In or Register to comment.