Howdy, Stranger!

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

Display a text when your variable/link is true and hidden when it is false.

edited June 2015 in Help! with 2.0
Hi I am new to twine. I am wondering if there is any command/macros I can use to make a specific text appear when a variable is true while not being display/invisible while it is false.
To simply put it I want my user to be able to create and track their own story by reviewing the decision they make in the story so far. Please and thank you.

BTW: I am using Harlowe

Comments

  • edited June 2015
    You can use if/else statements to accomplish this.

    In Harlowe that looks like this:

    (if: $someVariable is 1)[Print the stuff I have here]
    (else:)[Print only this]
    

    Or even:
    (if: $someVariable is 1)[Print the stuff I have here]
    (elseif: $someVariable is 2)[Don't print that. Print only the stuff I have here]
    (else:)[Print only this]
    
  • Thank You Sage it did what I want. Thank again
  • New user here too. I was looking for this as well, but in Sugarcube. Any chance you could show the code for that too, so that I can compare the two styles. I tried converting it already, but did something wrong, it never appears even if the variable is met. Even so I'm proud to have nothing appear rather than have an error message. It's a small victory.

    Also how does it read zero or handle a range of numbers? I read you use gt, lt, gte, etc but I always seem to get an error. Or do I use +=?

    You know I'm bored if I trying to learn how to code on my own. This seems sort of like an alien form of Sudoko, lol.
  • Thrown wrote: »
    New user here too. I was looking for this as well, but in Sugarcube. Any chance you could show the code for that too, so that I can compare the two styles.
    SugarCube <<if>> macro docs (2.x and 1.x).

    Basic examples:
    /* Similar to the Harlowe examples above. */
    <<if $someVariable is 1>> … <</if>>
    <<if $someVariable is 1>> … <<else>> … <</if>>
    <<if $someVariable is 1>> … <<elseif $someVariable is 2>> … <<else>> … <</if>>
    

    Thrown wrote: »
    Also how does it read zero or handle a range of numbers? I read you use gt, lt, gte, etc but I always seem to get an error.
    Range example:
    /* Do something if $someVariable is in the range [1, 5]. */
    <<if $someVariable gte 1 and $someVariable lte 5>> … <</if>>
    

    Thrown wrote: »
    Or do I use +=?
    That's an assignment operator. You don't use that in comparisons.
  • Thanks Mad, that helped a lot!
  • edited June 2015
    Here is an additional problem

    How can I make the text for two different variable to appear together when both is true?

    I am not sure if this is the correct way to explain this but what I am trying to do here is like a with each choice(different variable ) being selected more text will appear and it will build up like a story on a page.

    Is this a different thing and should I start a new topic?
  • You use the and keyword if both $variables have to be true:
    (if: $someVariable is 1 and $someDifferentVariable is "value")[Print the stuff I have here]
    (else:)[Print only this]
    

    You use the or keyword if only one of the $variables have to be true:
    (if: $someVariable is 1 or $someVariable is 2)[Print the stuff I have here]
    (else:)[Print only this]
    
    (if: $someVariable is 1 or $someDifferentVariable is "value")[Print the stuff I have here]
    (else:)[Print only this]
    
Sign In or Register to comment.