Here's an example of what's going on:
(set: $inventory to (a: ))
(set: $item_sword to (datamap: "name", "sword"))
(set: $inventory to it + (a: $item_sword))
(set: $item_sword's name to "broadsword")
(set: $inventory to it - (a: $item_sword))
(if: $inventory contains $item_sword)[sword in inventory]
(else:)[sword not in inventory]
As you can see I've added the sword to the inventory array, changed its name, and then tried to remove it from the inventory. But the final if-statement always tells me that the sword is still in the inventory.
The same thing does not happen when adding an item to the inventory, if I change the item's name and then add it to inventory that works fine. The issue happens specifically when you add the item to the array, then change its name, then try to remove it.
Anyone have any idea what's going on??
Comments
I will try to demonstrate what is happening using the following example: If you run the above code you will see that both $item_sword and $inventory's 1st change to "broadsword" but only $item_sword changes to "dagger", which indicates that $item_sword and $inventory's 1st are no longer referencing the same object after the first name change.
This is why your (set: $inventory to it - (a: $item_sword)) code is not working, because you are trying to remove an object (reference) that no longer exists in the $inventory array.