Howdy, Stranger!

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

[Twine2, Harlowe] Basic question: How do I say "(if: one of these is true)"?

Hey ya'all, just writing my first Twine thing and as I am generally not a master of coding (and to be honest, a bit logically impaired) I have some very simple things breaking every now and then.

Anyway, in my program I have five variables that represent "slots" for mercenaries, and they are not in an array or anything fancy like that, just Boolean values in variables. Now I have a passage where you buy a new mercenary, and it's supposed to check if a slot is free before you can sign the contract, ...
(if:$credits>=$price)[(if:$slot1,$slot2,$slot3,$slot4,$slot5 is false))[- [[Sign contract|Hire]]]]

This piece right here doesn't work since it checks if *all* of these are false.
Using "either" doesn't work because it randomly checks if one of these is false.
What I want is something like:
(if:$credits>=$price)[(if:$slot1 OR $slot2 OR $slot3 OR $slot4 OR $slot5 is false))[- [[Sign contract|Hire]]]]

... but that's obviously not correct Syntax (or did I miss something?).
I would prefer array-less solutions since it would require a bit of rewriting and I'm going to break stuff if I do that.

Comments

  • Try this. It has worked for me when I tested it.
    (if:$credits>=$price)[(if: $slot1 is "false" OR $slot2 is "false" OR $slot3 is "false" OR $slot4 is "false" OR $slot5 is "false"))[- [[Sign contract|Hire]]]]
    
  • edited August 2016
    Thanks for the reply, but I keep getting the message

    ...

    , even after changing all relevant instances of the Boolean to a string. Either I messed up somewhere or something here is not working right. Mind showing me the context of your code?


    Nevermind, found where I messed up. Thanks for the help!
  • Assuming that each of your $slot released variables contain either true or false value (eg. they are Boolean) then you need to use the not operator like so:
    (set: $credits to 10)
    (set: $price to 5)
    (set: $slot1 to true)
    (set: $slot2 to true)
    (set: $slot3 to false)
    (set: $slot4 to true)
    (set: $slot5 to true)
    
    (if: $credits >= $price)[
    	(if: not $slot1 or not $slot2 or not $slot3 or not $slot4 or not $slot5)[
    		- [[Sign contract|Hire]]
    	]
    ]
    
    note: I used indentation and extra line-breaks to make the example more readable, they can be safely removed.
Sign In or Register to comment.