Hey all, getting really stuck on this one and not sure how to figure it out. I have an array that acts as my inventory for items, works perfectly and fits the code that I want really well. Now I want to add a "quantity" parameter to all the items in the inventory. I'm having a bear of a time trying to figure this one out, even tried looking at a bunch of tutorials but they all just don't give me what I need.
What I have right now is simple:
var inv: Array[ITEM] = []
ITEM is a Resource script that has all the item info on it, name, strength, damage, etc.
For a little bit it seemed like I could change it up just slightly so instead of adding an ITEM to the array, I could add a dictionary entry. so instead of adding an item with "inv[#] = new_item" I would do "inv[#] = {"item_name": name, "quantity": 1, "item": ITEM }" which seemed like a good enough solution. I could get all the info I need right there in one place. But then I couldn't figure out how to extract that information! Like if I need to know the strength of the item in slot 5, how would I call that? "inv[5]."item".strength" doesn't work, but that's the logic I need.
I suppose I could just have a second array of integers, at that would hold the quantity of all the items. Its not a bad method honestly and I might just go with that, but if there's a simple way to keep it all together I would love to know about it!
and for a secondary part of this problem, I want to be able to have item drops in stacks. I am unsure of how to do this in Godot, but I know what I want the logic to look like. Again I want a simple array that would look like "var dropped: Array[ITEM, Quantity]" but of course, you can't do 2 variables in an array. The reason I want it set this way is so that in the inspector I can easily attach an item and set its quantity all in one place, rather than having to set it in mutliple places (like having one array for the item and another array for the quantity) so if there is a good way to solve this I would be thrilled to know!