+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 (63.1k 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.
...