It looks like you're new here. If you want to get involved, click one of these buttons!
(set: $inventory to (dataset:))
(put: "knife" into $inventory)
I can test if an item is in my inventory dataset
(if: "knife" is in $inventory)[You have the knife!]
What I can't do is -
Comments
The following code demonstrates the differences and how to dynamically add an item to a dataset.
As you can see, the $set1 variable (like your $inventory) changes from a dataset object to a string, $set2 starts off containing "dummy" and ends up containing both "dummy" and "knife", and $array starts and end similar to $set2. The (move:) macro is meant to be used to delete items from collections (like (array:) and (dataset:)) but I am not sure of the syntax required to make it work with a dataset object
P.S. You can use the dataset size property to check how many elements are contained within it:
For any of those using Snowman below is how you might do the same in JavaScript:
You can use the same method with arrays, too, which at least looks a little nicer in the code. eta: Oh, shoot. Those are both covered in greyelf's post, I feel dumb now.
This will show the key if you aren't already holding it: This will give you the option to take it: That lets you know you've taken the key, but it gives you the option to take it again if you ever revisit this passage (even though you already have it!)
So I try to test to see if you have the key before asking if you want to pick it up: However that doesn't work at all. Am I missing something?
BTW, Inspector Caracal you are far from dumb - you worked out what I couldn't without help.
eg. your example: (I added spaces to emphasized the point) Instead you should test to see that $inv does not contain "key" like the following, that way you dont need both an (if:) and (else:), note the extra parentheses around the contains conditional.
I kept trying not contains and not is in (& is not in) and every other variation I could think of.
So did I at first, I just kept at it a little longer than you did because I knew that it was possible! lol