0 votes
by (510 points)

I want to be able to check if a string doesn't exist in an array.

Basically, it's this except the opposite of 'contains':

(if: $inv contains "Phone")[[[Remove Phone]]]

//What I want it to do

(if: $inv does not contain "Phone")[[[Remove Phone]]]

 

1 Answer

+1 vote
by (156k points)
selected by
 
Best answer

You use the Boolean not operator to invert the Boolean value returned from the contains operator like so...

(set: $inv to (a: "Card", "Pen", "Keys"))

(if: not ($inv contains "Phone"))[You forgot your phone!]

 

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.
...