Need Help With Arrays

I currently have an array system where i Can pickup items and they get stored in my inventory. I’m working on a crafting system, what would be the best way to get what i have in my inventory and check if i have those items and if i Have the correct amount, and second question, whats the best way to setup a data management system for all the recipes for each item

Make a struct that has something like ID, Amount etc and make an array of of that struct, then you can do a For Each loop and look for that ID in the array.

I am not saying this is the best way, but this is how I would solve this issue:

I would have add an integer variable (let’s call it “Crafting Score”) with a default value of 0.

After, what you could do for the crafting system is you could have your inventory and all the items, but with an added square or rectangle somewhere which would be the crafting space.

Add a button over all of the slots on your inventory so whenever you click on one of your items in your inventory they will be added to this crafting space by a means of removing the visibility of the item in the inventory and adding the visibility of the item in the crafting space. (To prevent multiple items on top each other you might want to have set areas for each type of item, ie: sticks would be shown on the top left of the crafting space and apples would be shown on the top right)

For example, you could have a item of a stick and when this is clicked it will hide visibility of it on the inventory and show visibility on the crafting space.

After the stick is added to the crafting space, you would want to add a score (not set) of 1 to the Crafting Score integer you created earlier. Now, whenever you add a stick to the inventory the crafting score will have a score of 1 if nothing else is in the inventory but the stick.

Now, for an actual crafting system, say what the player would be crafting is a bow, they would add a stick to the crafting space which would add a score of 1 to the Crafting Score and then another item which would be a string. The string would add a score of 2 to the Crafting Score so the overall score of the integer is now 3.

All you would have to do now is have a branch connected to an event tick that would check to see if the value of crafting score is equal to 3. If it is, than you can set the score of Crafting Score to 0 and add a bow to the player’s inventory. This way, you could have infinite crafting recipes.

For example a rock would add a value of 4 to Crafting Score and the stick would have the value of 1.

Then you could have a branch that checks if the value of Crafting Score is 5. If it this, than it would add an item of an axe to the inventory.

(You may have to be carful with some of the math here, since 5 sticks or 3 sticks and 1 string would also yield the outcome of an axe so maybe you would have to play with the numbers so this wouldn’t occur.) .

There might be a more simple version to doing this but this is what I would do. Let me know if you’re having any problems with this.