Howdy, Stranger!

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

Or if (else)

No matter how nice is working in twine and harlowe, I'm always pushing the limits. Today, I tried for several hours to make an "or if" condition to work. This was the last thing I tried before giving up:
(if: $variable is "value1")[blue](or if: $variable is "value2")[red](else:)[yellow]

I already searched in the forum, but there are no topic that have "if or", "or" or "if".

Someone knows what I'm doing wrong?

Comments

  • edited June 2015
    Can you use "elseif" for your purposes? I get that there are different use-cases for using or vs using elseif, but I don't think Twine uses || (the normal double pipe symbol). It probably DOES have "or" syntax, but I don't know it.

    At least using "elseif" gives you something to start with so you don't hold up development waiting for an answer.
  • so, it would be something like this?
    (if: $variable is "value")[text on page](elseif: $variable2 is "value")[text on page]
    

    That actually worked.
  • edited June 2015
    So, @GreyElf, I'm glad you're here. I suggested the same elseif, but of course there is a different use-case for "or" vs "elseif", and about this use, I have a question.

    Is there an "or" syntax? For example if I wanted to say,
    if either THIS || THAT condition exists {
    one thing
    }
    else{
    other thing
    }
    
  • Try the following:
    (set: $variable to "B")
    (if: $variable is "A" or $variable is "B")[the variable has a correct value]
    (else:)[the variable does not have a correct value]
    
  • Awesome, thank you!
Sign In or Register to comment.