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
- 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!