I’ve started to follow an inventory system from PyroDev on Youtube. Now he’s not posting anymore videos from this series. Now i have some questions, i was hoping you guys could help a brother out.
When i add a new item to the inventory. it goes though this code:
So, when it does not find the item by name, it creates a new slot, that works just fine…but then, when it already have that item name in inventory, it goes through the “increase item amount” function:
That’s pretty straight forward. The node you’re using for “add” only ever adds 1 to integer and sets it.
If you want to add more you would need to grab current value + what you have picked up, then use set node.
Note that if you have max stack size for an item, you would need to make sure what you’re adding is not greater then your max stack size, if it is, you need to pass over the remaining quantity and create a new slot.
Naturally there will be a scenario where you pick up item that would fill all your “part” slots to full quantity and have some left over, but not more slots available. You would need to decide what to do, for example:
block pickup altogether
pickup what you can and re-drop the rest of the ground/floor. Think of it as common max gold/currency scenario in most game.
Please let me know, what you come up with and if you have more questions, ask away. Have fun!