Howdy, Stranger!

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

Harlowe What to type after an "If" variable, (:if $hassword is "false") = I want the player to lose

Hello everyone. I'm new to twine and am having trouble with Variables, specifically what to write after the above variable to create a link to another passage.

Also if there was a tutorial you could recommend it would be really helpful, thanks.

Comments

  • Well i'm not a very big expert on everything. only been using this for around 5 months but if im understanding you correctly you want to make someone go to another passage if a certain variable is reached.
    there are two ways i could think of doing this. one would be to make another passage entirely or another option if you want to keep it on the same passage you could use a (link: " ")[ command to send it to the passage. This is how I usually do it.
    (if: $key is "true")[(link: "key")[You use the key on the door. (goto: "next room")]]
    
    The key in this instance is the variable, whatever you want in the link between the quotes will be visable only when the $key is true. that way if they do not have the key the option wont be there. the goto command will run without you needing to do anything, but i like using links so there is a bit more control. If you want it to go straight to a passage without the reader needing to do anything i would do it like so.
    (if: $key is "true")[(goto: "next room")]
    
    so in your instance it would look something like this.
    (if: $hassword is "false")[ (goto: "lose")
    
    then make the passage loose whatever you would like your ending to be and then you can either have it stop there or loop it back to the begining.
    Hope this helps. Im sure @greyelf will correct me if there is a better way. if you have any other questions feel free to email me. I made one specifically for twine.
  • oh and be sure in the future to tell us what harlowe you are using. there are some differences between 2.0.0 and 2.1.1 and so forth so that always helps. :smiley:
  • If a variable is being used to represent a Boolean state (like Yes/No or On/Off) then you should use the true and false values, not the String values of "true" and "false".
    (set: $hasSword to true)
    (set: $haveKey to false)
    
    (if: $hasSword)[You have a sword.]
    
    (if: not $haveKey)[You do not have the key]
    
    note: the above code was written from memory and has not been tested.
  • I guess i still have plenty to learn about how to set things up myself. I tend to take really roundabout ways of getting to places. Thanks for the help.
  • Thank you all very much!, sorry for the late reply, this definitely helps and I'll get back into my storymaking. I'll let you know how it turns out!
Sign In or Register to comment.