[Sorted] How to Stack Items in a Structure

I’m very stuck… I’ve been trying for a while to work on an inventory system for my game, but I can’t get the items to stack properly. They kind of do, but they also duplicate. I don’t know/understand how to get items that are the same into the same slot…


Here are my external “Add Stackable Items” events. The event that’s bracketed in red is what “kind of” gets things to stack:

I got this far by following the official GDevelop inventory tutorial on Youtube, but until Part 3 is uploaded, any help would be very much appreciated! I tried asking for help on Reddit too (as to avoid posting here again so soon - it was on a different topic), but no luck… On the bright side, I guess, I managed to at least get the “stacking” to finally start from the number 1 instead of 2.

You’re not changing EmptysSpaceFound in the event you have in the red brackets. As a result, you are adding to the existing log, and then create a new log slot when you come across an empty one.

When you increase the value of a slot, you also need to set EmptySpaceFound to false:


BTW, you should really rename EmptySpaceFound to UseNextEmptySpace, because that better describes what the boolean variable is for.

1 Like

Thank you so much, it’s working now! I also changed the name of the boolean variable to what you suggested.
The fact that all I had to do was add one more action is both very frustrating, but relieving that I was on the right track. :sweat_smile: