Is it possible to search through an array for a specific string value and remove it? I only seem to be able to remove a value by index, but what if I don’t know the index of the thing I want to remove?
I have tried the ArrayTools extension, which has a condition for checking if an array contains a specific string value. But knowing my array has the value “dinosaur” doesn’t give me its index so I can remove “dinosaur”.
I have a simple single-row inventory. When an item is collected I add a string value to an array to keep track of items held and, as a consequence of how arrays work, the order in which items are collected (collection order is important, and that’s why I don’t just use a structure variable). In a separate structure variable I record the position of the item in the array (the index). When an item is removed from the inventory I replace the value in the array with the word “empty” so that the other items don’t move (get new indexes). If they did, I wouldn’t be able to target them afterwards because I would no longer know the value positions. By replacing an index value with string “empty” I ensure that my structure variable’s record of item positions stays accurate and I can continue to use that for item targeting. I have the game ignore any indexes with the value of “empty” when it populates the inventory.
How I currently “delete” an item from my inventory:
If I could target by value I wouldn’t need to cross-reference with a separate structure variable or create “empty” array values. Is there a way? My current set-up works, but I feel that there must be a more efficient way. Thank you.