Minecraft-Like Inventory


#1

I’m Working on a Survival Game and The whole Inventory thing is new to me. I’m Trying to Get an Inventory where if you mine the Tree or Rock that Wood or Stone would go to your Inventory. I Need Help with Getting the items to show in the Slots, For an Example If I Cut down a Tree a Wood would show in my Inventory and If I Mine a Stone I would get a rock to appear in the next slot next to the wood. Basically, I Need Items to Appear in a Slot if the Other one has an Item In it.

Thank you.


#2

I confess I’ve never played minecraft… but you’ve got several different things that should work together to make this happen.

I think you need to have a condition for acquiring the item, a condition for equipping/using an item, and a condition that finds the next available inventory slot once an item is acquired, as well as all the appropriate actions associated with those conditions: it’s actually a fairly complex system that needs multiple parts working together… but it can definitely be done with some work.

I can recommend you to start here:
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/inventory


#3

I’ve found that using a system that IDs your inventory slots is very effective. You use one object (one inventory slot) and create multiple instances of it, and then create an ID for each one with events like this -

This basically just cycles through the instances and gives them an ID. Then to have items show up in the first available empty slot, this is one of the methods i use -

When the player does something that gives them an item it switches a variable to yes, then it cycles through each inventory slot looking for an empty one, finds one and changes it’s animation to the item, then turns the variable to no so it doesn’t meet the conditions anymore and doesn’t continue through the instances
My system doesn’t deal with quantities (it’ll just put one item in each slot), but i think there’s a video on youtube about doing exactly that, and I imagine itd be pretty easy to do with conditions


#4

Inventory extension might help you. It is sometimes preloaded in gdevelop


#5

I don’t recommend it. It’s just a glorified less flexible structure variable.


#6

oh Is it, but it helped me a lot for a small and basic inventory system that I made. Then, is there any other way?


#7

Using structure variables. http://wiki.compilgames.net/doku.php/gdevelop5/all-features/variables#structure_variables