Howdy, Stranger!

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

Health variable tracker help?

So I'm making a health tracker for a game I play and I need it to start with 20 health and have a button to add 1 and subtract 1 health but I want them both to change separately.  How can I make the [[+]] and [[-]] to show a plus and minus but be called something else? so they both go to seperate passages but wtill both say the same thing?  Here's the code so far:

<<set $health1 to 20>>
<<set $health2 to 20>>
Player 1: [[-]] <<print $health1>> [[+]]
Player 2: [[-]] <<print $health2>> [[+]]

Comments

  • I think all you need to do is have
    <<set $health1 -= 1>>
    on the one you want to minus the health and if you want it to also add 1 or subtract 1 to health 2
    <<set $health2 += 1>>
    If you want it for health1 just change it from 2 to 1. I hope that's what you mean.
  • If I read you correctly, you'd like to display the plus or minus symbol, but have the link going to something other than a passage called plus or minus, and change the value when it is clicked.

    See http://twinery.org/wiki/link for details if this is the case. The general syntax is [[displayed text|title of passage][$variable = expression]]
    so
    Player 1: [[-|player1passage][$health1 -=1 ]] <<print $health1>> [+|player1positivepassage][$health1 +=1 ]]

    Player 2: [[-|player2passage][$health2 -=1 ]] <<print $health1>> [+|player2positivepassage][$health2 +=1 ]]

    If you'd like to stay on the same passage, and have the scores change, the <<replace>> macro might be what you're after- see http://www.glorioustrainwrecks.com/node/5462
    It's a little tricky for new users (like me) but the example at http://www.glorioustrainwrecks.com/files/TwineMacro-ReplaceTest.html#2.1 shows what an excellent macro it is an d how valuable it is.
Sign In or Register to comment.