I have an Inventory Array which I wish to go thru all the items in this array.
I have most of the functionality working except going thru array to check items, so I can setup stacking the inventory by adding +1 to the item (to track how many items I have in the slot).
When I click on item in game world, I would like to to check:
If the clicked items match the class, then add +1 to that class of item.
If the clicked item does not match, then go to the next item and do check if item matches class again.
What happens is I add the item to the array, but it does not stack the items. Instead it adds both items.
My Question:
If I use a Loop, do I need to remove the previous item in the loop that matches the item?
Or is there a way to do a check on all items in the loop, then if one matches… do the +1 to stack the inventory item.
One question though, you said you are adding +1 when you find a match. Exactly where do you intend to perform this increment operation? Is it a separate array of 'Int’s? You can use the Index pin to sync the two arrays.
Anway when you’ve found your matching item, you can do the logic you need (adding +1 in this case) and feed back to the ‘Break’ pin of for-ach node. This will make sure that once a match is found, looping is stopped immeditaley.
If you can post a pic of your blueprint, I might be able to help more.
The +1 was placed on variable [CurrentStackCount] on a Parent Item Blueprint.
It is separate from the inventory array.
What your recommending is having 2 arrays, one for Inventory Items(which I have). Then an Array for Items in each slot?
I currently am using Parent Blueprints for the Pickup Item. This Parent item has its own “CurrentStackCount” int. So I just +1 every time I find a match.
I can find the match, but having issues with checking the rest of the array. Curious if I loop thru whole array to find matching then somehow save this data in variable… or once find matched item, +1 the stack count. Then find if matched on other locations of array, if matched delete that item.
I am still clear about your logic here. So I am speculating. However if you could show me the blueprint, I ight be able to help.
Anyway, Let us see if I got it correctly.
Your Inventory array contains several objects. All these objects has a Parent Item meber whcih is anotehr blueprint. You want to loop though the items and when you find a match, you want to increment a counter on the Parent Item of the matched inventory item. Did I get it right?
Also I would like to know if your inventory item array will contain duplicate instances of the same item? If not, you can immeidtaley break once you find a match and update the counter. Ottherwise you need to set a boolan vairable to indicate if a match has been found nor not and continue with the rest of the array. Delete any duplciate entries if the boolean flag is set.
…still I am assuming too much. If its possible, try to uplaod an image of the two blueprints in question.