Why is my code not working?

Hi! I’m new to twine and working a basic game.
(if: $item1=1 , $item2=1)(goto: "[[optionA]]")
(if: $item1=0 , $item2=0)[(goto: "[[optionB]]")

This is the code i’m currently using. I know an if–>then–>else system would be better but i can’ t figure out how to write one. When i try it it says that neither options exist when an arrow is going to both options and that i need an -item before both item1 and item2. I’m sorry if this is a silly question but I can’t seem to find an answer any where. Thank you guys so much!

1 Like

For starters, it might help to take a look at the operators that Harlowe uses for Boolean logic. In this case, where you’re using the = sign, you actually need to use is instead.

The documentation doesn’t seem to cover what to do if you want to check the values of multiple variables in one if-statement (as far as I can see? though I might have missed something), but you want to use “and”, not a comma.

You also want just the quotation marks, not the double square brackets, in your goto, like in all the examples in the documentation here.

Finally, you need to use a hook after the (if:) macro for anything that you only want to be displayed/run if the macro evaluates to true. So: (if $item1 is 1 and $item2 is 1)[(goto: "optionA")]

What are you having trouble understanding about the use of else-if?

(By the way, when posting code, it helps to use the “preformatted text” option, which you can do by highlighting the text and clicking the button at the top of the post window that looks like </> or by manually typing backticks (` - the key left of the 1 on a QWERTY keyboard) around the text.)

1 Like

thank you so much! that was really helpful the code is working better now except when I play through it automatically goes to the same option rather than the option I coded in. I saw a couple other posts on a different foram for twine mention the same issue so i’m not sure if it’s a bug or if I made a mistake. thank you again that helped me a lot in other areas as well!


  • The 1st line of the (if:) macro’s documentation (eg. the “usage” line) shows that the argument passed to the macro needs to be a Boolean (value or expression).
  • And the list of Operators in the Boolean type’s documentation includes information about using the and & or join operators.

Yeesh, I even linked to the operators and I still missed it in the list. Thanks!

1 Like

As already explained by E. Joyce you need to:

  • use the is keyword comparison operator instead of a equals sign (mathematical) base comparison operator.
  • use the and operator in each of your (if:) macro calls to combine the two individual condition expressions to form a larger multi-part one.
  • place each of the conditional (goto:) macro calls within a Hook, that you associated with each (if:) macro call.
  • change the String value you’re passing to each of the (goto:) macros to be just the Name of the Target Passage.


(if: $item1 is 1 and $item2 is 1)[(goto: "optionA")]
(if: $item1 is 0 and $item2 is 0)[(goto: "optionB")]

However, because the above multi-part conditional expressions are what’s known as Mutually Exclusive (1), the 2nd of the (if:) macros should be an (else-if:) macro instead.

(if: $item1 is 1 and $item2 is 1)[(goto: "optionA")]
(else-if: $item1 is 0 and $item2 is 0)[(goto: "optionB")]

(1) Mutually Exclusive is when two (or more) things can’t be true at the same time.

1 Like

that was great thank you!