How to find a BP class in an array of structures?

I followed this tutorial null - YouTube by Invicta Studios/AntiquisTheGame which creates an inventory of items that are all children of a master BP class that holds an itemData struct which holds core details like name, class, details, weight and then creates item stacking (ie 2 rocks collected = “2 rocks” inventory button) which is acheived with another struct, itemStacking which holds an array of itemData structs and an array of ints for amount.

Its built this way http://blueprintue.com/view/1gt-WajG/ (image here) so basically when you open the inventory screen it clears both the itemData & int arrays (items & amount, respectively) in the itemStacking structure then the first ForEach loops through an array struct which is also an array of itemData structs.

So the 1st ForEach(itemData struct in array “inventory”) body is

  1. ForEachLoopWithBreak(itemStacking.items (aka itemData struct array)) break the array element (itemData structure) and if the item is stackable (by checking if the itemName string in itemStacking is == itemName string in inventory. If it is stackable (true) then SetArrayElement(itemStacking.amount (aka int Array in itemStacking)) index = array index from this loop and item = Get(amount, index = same array index from this loop +1) which then feeds into the break.
    If false (not stackable) we just set it to 1 via set int itemStacking +1

Then once thats completed it goes into a branch to check if the int variable itemStacking == Length[itemStacking.items] if true Add(items, new item = array element from the first loop (itemData array ‘inventory’), if false we set itemStacking back to 0 to be ready for the next go around this big loop.

Now I’ve created a crafting system that works off this. Very similar. I can populate the “have items” list the same way I just described and the have list which is just an int for each of “rocks, ironOre, sticks” etc. and my recipies are also based off a master BP class that holds a recipie struct and an array of all recipies. The recipie struct holds deatils like recipie name, required items (ints) and class to craft.

**I cann’ot for the life of me figure out how to find a class in a struct. ** I need someway that for each int value (ie ironOre = 2) find if its in the inventory and then remove the index(s).

I tried something along the lines of getting the itemStacking sruct, breaking it, then Find(Items, make itemData(class = BP_rock)) but I always get a -1 (aka item not found)

Heres the general setup I’ve been playing with in its simple form and where I’m stuck at. http://i.imgur.com/nxpZta6.png

I thought about replacing the recipie master class struct with data tables now that we can set assets to cells in 4.8 but its in its infancy so “getTableRow” is a little limiting. That said, visual structs are a little limiting too.

I’m able to code a BP function libray if required if anyone has any hints, tips, or ideas.

I know there is people in the same boat cause I’m making a vaideo tutorial on this so that people have somewhere to turn to for this common “Crafting” problem.

Thank you.

Willing to paypal a 20 or something for some 1on1 tutoring via skype, willing to share the project also to anyone who is intrested in this.

Edit: I also tried breaking the recipie, then making the find with classes connected between them, but no avail. Like this http://i.imgur.com/3h6Bwzz.png

I should add something like this returns 0 no matter if i have x number of items before “2 x rock” or whatever. http://i.imgur.com/AJ1Qxx2.png

I should add if I replace the itemStacking items array with the inventory array it works (this works ie iron ore found at 0 rock found at 0
) http://i.imgur.com/HnXTdLZ.png

Hopefully I can remove the index and have everything still work properly. And find more elegent solutions!

Ok I got it removing the index. Any tips still appreciated! This will require nested forLoops for EVERY int for every item in the selected recipe. I hate nesting anything.

Edit: This after much experimentation (been stuck on this for a couple weeks), is the furthest I can get. As long as the rocks are the first item in my inventory it works. If any item is before “rocks” then it wont remove any indexs’.

Does this seem the correct way to do this, for each item in s_craftingMain (that is, every craftable item which has an int) and once all of those remove their items, then spawn the class?

Its removing the right amount of items at least.

http://i.imgur.com/qof5ZN4.png

Tips? I’ve made it further than I thought.

Edit: More experimetation and talking with my peers. I was removing index 0, so of course it was only working that way. ’

This seems to work now no matter the order of items. So, just repeat this for all items? What about recipies that have say rocks = 0. Will my setup still work and move onto the next item? (If the next item is the same setup, with a different class, different hasX var, and executes on “Completed”?

http://imgur.com/qJ6Nwh9 working version “so far”

>This after much experimentation (been stuck on this for a couple weeks)
thats sucks, i have same issue with networking concept :frowning:

few ideas come to my mind when i think about inventory and recipes, i dont know which is actually correct, depends on how many recipes you need and how complicated they need to be.
Most promising one is making a struct with recipes, go throw each row of that struct with your item and after each hit check existence for all other recipe items in your inventory.

i see you make guides and stuff, add me on skype so i can parasite on your knowledge 2.png and help with inventory concept.