Hello! So I have an inventory which is an array:
<<set $inventory = []>>
I then create objects to populate the inventory:
<<set $book to { name: "Book", value: 70, description: "Text here" }>>
<<set $inventory.push($book)>>
Everything works fine, except when I check if the player has the item in the inventory:
<<if $inventory.includes($book)>>
[[show book]]
<</if>>
The only time it works is when I place <<set $inventory.push($book)>> in the same passage as the check.
I checked in the old forum and came across this thread with the same problem:
https://twinery.org/forum/discussion/comment/23380/
So now I know the reason why it doesn't work.
What I want to know now is one of the solutions proposed:
"You could give each object you wish to use in this way a unique property and check for that"
Let's say I give $book a unique ID
<<set $book to { name: "Book", value: 70, description: "Text here", ID: 001 }>>
How do I check for the property of an object inside an array?
Thanks