0 votes
by (120 points)

I have an inventory system and some passages that are only accessible if the player has an inventory item.

I'm having trouble writing a statement to change the player's options if they have item 1 OR item 2. I know how to write the statement if they have item 1 AND item 2, but I'm not sure what the code would be to allow them to have either item to qualify for an option.

What I have now is this: 

(if: $inv contains "item1")[ [[passage1]] ]
(else:)[ [[passage2]] ]

(if: $inv contains "item2")[ [[passage1]] ]
(else:)[ [[passage2]] ]

The problem is if the player happens to have both item 1 and item 2 in their inventory they will have double the links. And If they have item 1 but not item 2 the link for passage 2 will still show up when I don't want it to. I only want them to see a link to "passage 2" if they do not have either of the items.

So I'm looking for something kind of like this, keep in mind I'm not sure what the code would actually be.

(if: $inv contains "item1" or "item2")[ [[passage1]] ]
(else:)[ [[passage2]] ]

 

1 Answer

0 votes
by (159k points)

You need to include the $inv variable in each of the sub causes of your conditional expression.

(if: $inv contains "item1" or $inv contains "item2")[ [[passage1]] ]
(else:)[ [[passage2]] ]

 

by (120 points)
Thanks so much! this was exactly what I needed!
...