Download

Find/ Remove All of "Item Type" From Array

Hello, what I am trying to do is remove multiple of a single type of item from an inventory array in my game. For example if a players inventory contains “Fish, Apple, Sword, Axe, Apple” and the cost to get in somewhere is “Two Apples” I need to perform a check on that players inventory and make sure the player has two apples, and if so remove them.

I have been able to accomplish this if the cost is just 1 Apple. I have attached a screenshot of how I use the “Find” and “Contains” nodes to accomplish this.

However the FIND node only returns an index number of the first slot that it found the item in. I need a way to find the index of each slot that an Apple is in and then run the remove item function for each slot. So if the cost is two apples, find index 2 and 5 from previous example and remove items in slot 2 and 5 once they have been found. If not tell the player they do not have the items required.

Please help with some ideas on what this workflow should look like. I realize that once 1 item is removed, the array is resized and the index slots will be renumbered. So the solution will have to take this into account if I am going to remove 1 item at a time.

If you need any additional information to help me, let me know and I can post more screenshots or fill you in on whats going on.

Thanks!