+1 vote
by (550 points)

I'm using an 'if' condition to control if a link shows up in the list of options. It works fine, up until the link is supposed to disappear again.
Here is my code:

<<if ($inventory.includes("Key") && not $Door.openCondition)>>
<<link "Unlock" "unlockDoor">><</link>> the door<</if>>\

Key is in inventory: <<= $inventory.includes("Key")>>
Door is locked: <<= not $Door.unlockCondition>>
Both: <<= $inventory.includes("Key") && not $Door.openCondition>>

These are the results I get:

Before getting the key:

Open the door
Take the key

Key is in inventory: false
Door is locked: true
Both: false

After getting the key:

Open the door

Unlock the door

Key is in inventory: true
Door is locked: true
Both: true

After the door is unlocked:

Open the door

Unlock the door

Key is in inventory: true
Door is locked: false
Both: true

 

What's going on? How do I get a conditional to react to one of the conditions turning false?

1 Answer

+1 vote
by (61.7k points)
selected by
 
Best answer
You have two different properties there on your $Door variable: unlockCondition and openCondition.  Are you sure all your variable names are correct?
by (550 points)
Ugh, well I feel like a real dummy... Thanks you for your time!

I sometimes wish it was easier to look at passages side by side in the twine app.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...