I’ve watched many tutorials on inventory systems and I’ve seen most of them have some type of Slot index, I’ve made an inventory system and I’ve tried to implement something that needs to know which slot is which. I’ve made chests and I can’t figure out how the slots individually are indexed. Can anyone explain how Slot indexes are set? Either I’ve set it and totally forgot about it or theres something deeper that I don’t quite understand. I want to understand how inventory slots are indexed individually and how they’re made unique. Thx for your time.
Can anyone explain how Slot indexes
are set?
Each slot is a separate widget that has an integer variable. When the slots are created, they’re given ascending IDs int +1; here via an exposed variable. This would work OK for a hotbar or a diablo-style inventory.
For something more elaborate, like slots for character’s equipment, an enumerator is a much better choice for an ID system. And for something even more elaborate like dockable / swappable / modular slots, you could look into utilising Named Slot widgets - think of them as of a placeholder slot where users can dynamically insert / remove any other widget.