Howdy, Stranger!

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

Probably a simple question regarding Either and If

Hey, I'm new to Twine and I'm having an issue with Either and If.

Earlier in the code I use an Either:

<<set $friendThree to either("Dog", "Bear", "Frog")>>

And that works fine.

Then later on the same page I want to have it be where the verb of the animal's dialogue changes depending on what was selected randomly. So right now I have it like:

"Hello" <<print $friendThree>><<if $friendThree is "Dog">>woofs.<<elseif $friendThree is "Bear">>growls.<<elseif $friendThree is "Frog">>ribbits.<</endif>>

But it can't find the matching tag for the If macro so clearly something is wrong. The elseif ones appear to go through but it's hard to tell.

Can I not set a name in this way? And if not, could someone explain if there is a way to achieve what I'm trying to do?

Sorry if I'm missing something obvious.

Comments

  • Hi,

    i think there is no slash before endif.
  • Like Gruik said, there's no slash before <<endif>> and that will fix the issue with finding the appropriate verb.

    You also want to add a space before the verb for clarity otherwise it will print "Dogwoofs" or "Beargrowls" or "Frogribbits".

    Corrected code below:
    <<set $friendThree to either("Dog", "Bear", "Frog")>>
    
    "Hello" <<print $friendThree>><<if $friendThree is "Dog">> woofs.<<elseif $friendThree is "Bear">> growls.<<elseif $friendThree is "Frog">> ribbits.<<endif>>
    
  • Thank you SO MUCH. Loving Twine so far, hopefully won't hit too many snags like this again.

    Thanks again.
Sign In or Register to comment.