# find items and amount in struct array(BP)

**URL:** <https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [June 9, 2015, 12:36am UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037 "2015-06-09T00:36:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 9, 2015, 12:36am UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/1 "2015-06-09T00:36:19Z")

</div>

Ello everyone thanks for taking the time to read

im currently working on a crafting system, I currently have a stacking inventory i can pickup and drop items. But i seam to be having trouble when it comes to the crafting bit. It seams contains/find do not work on a struct array(or maybe im doing something wrong. I can run a foreach/break the inventory and run a = to see if the item name is in the array and that does work, but im unable to get the amount and index of those items

any help with this tidbit would be greatly appreciated

Thanks again

Lordevilpoptart

---

<div class="post-metadata">

**Author:** ![KVogler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KVogler](https://forums.unrealengine.com/u/KVogler)\
**Post date:** [June 9, 2015, 2:03am UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/2 "2015-06-09T02:03:25Z")

</div>

You have to store the found value in a variable because the Element pin of the loop node is no longer valid after the loop exits.  
See here, the found column structure (which contains substructures) is stored in “FoundColumn” which is then used in the “Completed” branch.  
(Ignore the error on the “PlaceElements nodes”… They are unrelated)

 ![BPOutBug02.JPG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/7/e7f23e5a4b24bbc337f513ba20dc981af1d73d17.jpeg)

---

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 9, 2015, 3:35am UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/3 "2015-06-09T03:35:32Z")

</div>

thanks for the reply  
The way i currently have it setup when i click my recipe it gets the class associated with that and i cast to my masteritemBP. from there i can grab the struct of required ingredients. I need to compare that to what is in my inventory then remove the ingredients from the inventory when i click build  
maybe im just tired, or im not advancing as well as i though i would, but i don’t see how i’m going to get the number of say ingredient 1, and ingredient 2 that i need and be able to remove them from my array. My struct is not sub structures. It contains Name(string) a thumb nail, some bools, the item class etc.

I understand the passing it to a new variable(as you said once the loop is done its not valid anymore) I have the loop body checking a bool of isingredient and passing true into the new variable if i use that variable to do a print sting it prints the last item i picked up,

Do i have to run this for each ingredient im trying to find? for testing purposes im trying to build a spiked bat requiring 1 bat and 4 nails. ive done quite abit on my own and some with help of tutorials, but i just cant wrap my head around this part.

---

<div class="post-metadata">

**Author:** ![Snow901](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Snow901](https://forums.unrealengine.com/u/Snow901)\
**Post date:** [June 10, 2015, 5:26pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/4 "2015-06-10T17:26:04Z")

</div>

I recommend you add an ID integer to the master item class to make it easy to find objects by an integer ID (although you could do this with text if you wanted the ID to be specific like IE4300, IE4301, etc… I haven’t gotten around to trying this method out myself yet). For quantity, you can make an integer on the master item class called Quantity to keep track of how much of that object exists.

---

<div class="post-metadata">

**Author:** ![KVogler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KVogler](https://forums.unrealengine.com/u/KVogler)\
**Post date:** [June 10, 2015, 5:30pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/5 "2015-06-10T17:30:12Z")

</div>

> [@](#):
>
> I recommend you add an ID integer to the master item class to make it easy to find objects by an integer ID (although you could do this with text if you wanted the ID to be specific like

The “Name” type should be equally fast, as its just comparing the indices of thes strings in a table…  
More info: [https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/index.html](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/index.html)

---

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 10, 2015, 5:51pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/6 "2015-06-10T17:51:11Z")

</div>

Ok so im messing around with it and i can get an item of the name and set it to the variable and print how many there are, and i can do this for each item i need. however when i print it out it works fine if i have one item in my inventory but if i have mutiple things in the inventory it prints the item X the number of things i have total but for the amount the second and third print multiples the number

---

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 10, 2015, 5:53pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/7 "2015-06-10T17:53:42Z")

</div>

![finditems_amout.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/5/ca5b5486d332f40634a541f4de37ca1957a0e237.png) ![printitemnameandamount.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/0/7e0bd74b3ec2480c220da6299db75bd8cc6391b9.png)

---

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 10, 2015, 5:55pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/8 "2015-06-10T17:55:48Z")

</div>

[attach=con[attach=config]43078[/attach]fig]43077[/attach]

---

<div class="post-metadata">

**Author:** ![lordevilpoptart](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lordevilpoptart](https://forums.unrealengine.com/u/lordevilpoptart)\
**Post date:** [June 17, 2015, 6:20pm UTC](https://forums.unrealengine.com/t/find-items-and-amount-in-struct-array-bp/32037/9 "2015-06-17T18:20:24Z")

</div>

all figured out!!! i now have a working crafting system
