Howdy, Stranger!

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

If eq for 2 or more items?

edited July 2016 in Help! with 1.x
I am making a project where you type in a word and it brings you to a page based on the word. I am trying to make it so if the word is not a page, it does not go anywhere. I tried

<<if $command eq/is "page1" or "page2"...>><<goto $command>><<else>><<goto "Start">><<endif>>

that does not work, and I also tried

<<if $command eq/is ["page1", "page2",...]>><<goto $command>><<else>><<goto "Start>><<endif>>

which does not work either.
(note:I did not literally but /is, i just tried both commands)

If I am doing anything wrong, could somebody tell me?
If there is a better command, what is it?

Comments

  • You need to state which Story Format you are using when you ask a question, as answers can be different for each one.
    Because (from memory) the <<goto>> macro is not part of the standard story formats I am going to assume you are using one of the SugarCube story formats.

    The Logical operators section of the Twine 1 Reference contains a list of the operators supported by the standard story formats, two of those operators are: and and or

    Those two operators can be used to evaluate multiple expressions at the same time, as demonstrated by the example directly following the operator list.

    So your example should be:
    <<if $command is "page1" or $command is "page2">><<goto $command>><<else>><<goto "Start">><<endif>>
    
    note: A similar list of operators can be found in SugarCube's <<if>> macro documentation, I did not use that list because the example following it does not show how to use the and or or operators.
  • Thanks!
    (I thought I put sugarcube in the tags :\)
Sign In or Register to comment.