Hello, CodeAlpaca here ! A ton of people ask for this so I wanted to make this while helping out another user.
What this example includes: It’s important to note that this isn’t a one-size-fits-all type of thing, so I have to clarify what this example does
- Allows you to easily add and remove items.
- The number of items easily stack
- Includes a way to display this inventory. (Spawns a grid as well)
Of course, there will most likely be minor changes that will need to be made to exactly fit your game, but it should be easy.
What does it NOT do:
- There is no limit to the stacking. It doesn’t cap at 64 like Minecraft. However, this is really easy to add.
A+1 > B? 0 : A+1
// If it's equal to 0, you DON'T want to add it.
- All items automatically move to the lowest slot. This means you CANNOT place items anywhere like you would in Minecraft.
- You don’t know if you picked it up or not. I didn’t want to overcomplicate this, so I did not include this.
Imagine you had an apple, and you try to pick it up. You should know if it was picked up before removing the apple from the ground. This can be done with “Reply to last message” after it is confirmed you picked up the item (You’ll know information when it is added to the inventory)
I’ll have to make a Minecraft style example after this, because I’m sure that’s the first modification people will want (being able to place it wherever you want, and a stack limit. Though the stack limit is easy). + also showing a way to not pick up and item if the inventory is full. Another relatively easy thing to do, but will still be included once I make a more Minecraft style version of this.