Howdy, Stranger!

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

use variables with if/else statements?

100% novice to both twine, and coding generally.

I'm testing out a story where a character wants to do something (eat, in this case), but can't until a variable ($agency in this case) = 1 or greater.

There's a Kitchen passage with the following structure:

<<if $agency <=1>>You're really hungry, actually. You should Eat. <<else>>DoNotEat<<endif>>

When you go through DoNotEat it leads to a sequence that will set $agency to 1 and lead back to the Kitchen.

However, setting $agency to 1 makes it so the very first time you play, you skip directly to Eat.

Am I misunderstanding something about this?

I'm using twine 1.4.2 for windows. No frills, add-ons, or anything special, just the download link on the frontpage.

Comments

  • Your $agency <=1 is true when $agency is less than '<' or equal to '=' 1
    Try using $agency >=1' which is true when $agency is greater than '>' or equal to '=' 1
  • ...omg. I'm not gonna live that one down anytime soon. Thank you!
  • ...omg. I'm not gonna live that one down anytime soon. Thank you!
    lol, we all make silly mistakes.

Sign In or Register to comment.