Howdy, Stranger!

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

Help with pretty basic variable issues.

Hello there,

I'm having some fairly basic issues with setting variables and then calling the value late in the game. I've checked the Google group and read the reference a thousand times, but I still apologise if I have missed something obvious.

(Using Twine 1.4.1)

So, I set a variable at the top of my second passage (the first passage is a title page, but maybe I should set my variables there?"
<<set $variable1 to "0">>
Later on I [
<<set $variable1 to "1">>
.

I then want to call the variable with an <<if>> function:
<<if $variable1 is "0">>
text 1
<<else>>
text 2
<<endif>>

However, even if the player has had variable 1 set to 1, "text 1" is still appearing. Surely, as they do NOT have a variable value of "0", "text 2" should be appearing.

What am I doing wrong?

Thank you for your help.


Comments

  • Attach a basic test .tws file that demonstrates the problem you're having.
  • Try inserting some <<print $variable1>> statements around the place so you can see what's going on...
  • I was having some problems with variables not being updated/set properly. I was using radio buttons and stuff and apparently clicking a regular link [[Next|passage]] doesn't update it. You need a button <<button [[Next|passage]]>>. I don't know if this will help, but might be worth a shot.
  • I was having the exact same problem with my if statements last night, but I was really tired so I thought I might be typing them wrong. I went and grabbed an if statement from one of these forums and pasted it in, then changed the variables and conditions and it worked fine. I discovered if I typed it in, Twine didn't recognize it, but if I wrote it somewhere else and copy/pasted it in, suddenly it worked.

    It's an insane workaround, but I don't have time to figure out why and I'm just going with it!
Sign In or Register to comment.