Fix my inventory

I’m making an inventory for my game and I’m using the GDevelop example game coding. However, whenever I click on what should go in the inventory it just disappears and is nowhere to be seen. I checked over the coding, but everything seems fine and I don’t know what I did wrong. Any help is appreciated.

How are you displaying the items in player_inventory?

I’m not exactly sure what you mean…

Sorry, bad question.

I should have asked, do you have all the items as animations in inventory_slot? In the GDevelop example, when you edit inventory_slot, it looks like:

Is this what yours looks like, with the name for each animation?

And have you given each item on the screen an instance name, to match the animation name of inventory_slots:


1 Like

Ohhh…I see what you mean now. And it wasn’t a bad question…I am just an inexperienced coder. I have the items as animations. But, the items I have don’t have instance variables. I am going to try what you said and get back to you on it in a moment.

Edit: I have tried it and now there’s a different issue: when I click on the item it adds to the inventory count (the number adds +1 like it’s in the inventory slot), but it still doesn’t show up anywhere :c

Do the names in the instance variables and the animations match? I believe they’re case sensitive too, so keep that in mind.

1 Like

Okay, let me check that and I’ll get back to you.

Sorry, I took so long to respond. I made sure the animation names matched with the instance variables and it still didn’t work. Even though the example code didn’t have this in there from what I saw, could I just add a change animation (and have the animation change to the item that’s clicked on) to actions and try it that way?

Try this run your game with debugger and check if the values of inventory_slot are there or not and if is there then. Check again your inventory_slot animations.

Make sure the instance variable are set to number for quantity and as string for the name, just click the wrench icon and check if those instance variable has the correct assign.

Also in debugger check if your collectable items has the same name that the inventory_slot has.

for instance if you have a collectable banana Sprite this need to have an instance name = banana so when you collect this item compare its name to match the same name in the inventory_slot name instance.

Can you also check each item’s instance variable names (“name” and “quantity”) are all lower case in the editor? And that they don’t have any spaces.

Yup, no spaces and it’s all lowercase. Maybe I missed something in the coding…?

Okay. I’m going to run it with debugger…I’ll get back to you once I have tried everything that you have advised.

Edit: I think it might be that the name of my sprite is not the same name as the item I want to pick up (name of sprite is “JournalPages” and the instance variable name is “paper”). Is that what you meant by the names in the last sentence?

Hi I’m not at my pc now when i can I will share my inventory events to you so you can check how is made

1 Like

Okay, that’s completely fine. Thank you for helping btw!

Hi again, I’m going try to explain my inventory.
The Items is an external layout with the items slots as you can see the items have a lot of instances but need to check only the inst_name and inst_number

This are the items itself, note they have the same two instance variables inst_name, inst_number

This is an event in game to collect the item, i think in your case you’re adding items on click right?

This is how the player buy an item

All working together

Unrelated comment: really cool game! However, I still don’t know what the problem could be even with the debugger since I’m not super familiar with using it. The variables and everything match, but I don’t know what else I might’ve done wrong because the object just disappears, but the quantity is added to the inventory slot. It’s just that the actual object disappears and the animation doesn’t change to the animation 1 or “paper” when the object is clicked on :c

I suspect it’s something in the scene itself, and not the events. Would you want to share your project so someone can have a look at it?

That’s completely fine. How would I go about doing that? And also thank you for your help so far!

Zip it up and upload to to a file server - google drive if you have it.

1 Like

Alright, gotcha. Give me a moment to do that.

Edit: Here is the link c: