Hello,
I’m trying to set up an inventory system which can keep track of different types of ammo and quantity. I’m trying to make a function that loops each item in the inventory, checks the ammo type of each item, adds the quantity together so i get a total for each ammo type. The best i came up with so far looks like this:
what the ammo struct looks like:
When I print text it seems to work only for the M1Ammo, as I pick up or remove M1Ammo from my inventory it will show the correct numbers. However, for the Molotov ammo, it prints out 4x of what I have in my inventory. So I have 4 molotovs in my inventory, for some reason it prints out 16. I get this error:
it repeats a lot. I’m not sure what I am doing wrong, I checked the ammo variables and they are correct, they are taken from a data table. I appreciate any advice, I’m not sure how to fix it or if there is a smarter way to do it. Thank you for your time