Howdy, Stranger!

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

How do I add to a value??

Stupid question but I can't seem to add to a value.

For instance. If I put...

<<set $whatever is 0>> then it displays as 0, then I have <<set $whatever = +1>> and it becomes 1 but revisiting that last passage doesn't then make it 2. It just stays set at 1. I guess I'm just re-setting $whatever to 1 instead of adding to that value.

I realise this is basic stuff but I can't seem to find the answer anywhere.

I'm currently using sugarcane.


  • The is operator is a comparison operator (it tells you if the left-hand and right-hand sides are identical). For assignment, you want the to or = operators, like so:
    /% TwineScript style. %/
    <<set $whatever to 0>>
    /% JavaScript style. %/
    <<set $whatever = 0>>

    To add 1 to the current value of $whatever use one of the following:
    /% Long form. %/
    <<set $whatever to $whatever + 1>>
    <<set $whatever = $whatever + 1>>
    /% Short form. %/
    <<set $whatever += 1>>
  • Ah, thanks! I thought I'd tried that already. Evidently not.
Sign In or Register to comment.