[Solved] Im trying to follow a inventory example but it doesnt seem to work right with me

so I’m trying to follow an inventory example but it seems like only 20% of it works for me. like the part where it changes the icon background and deletes the item you clicked on works but the thing I need help with is making a number that shows how many of the same items are in a slot show how many are there because it always shows as 0 even when there are items in the inventory



In that “At the beginning of scene” section, you’re repeating through all IconBackground objects, setting the Name_Of_Item of IconBackground to “”.

Then in the next event you repeat through all Number_of_objects, and set it to the count of the linked IconBackground.Name_Of_Item. This object variable will be blank and, as there won’t be any items there, it’ll return 0.

So what do I do exactly? also here is a video (Sorry for bad quality) record_000001

I’ve had a closer look, and don’t understand why you are hiding Number_of_Objects.

But more importantly, you’ll need to provide more events - where are you adding the items to the inventory? Where else are you setting the text of Number_of_Objects?

im hiding the number of objects in the begining of the scene so when the scene starts the numbers wouldnt be visible, also did you see the imgur link?

I believe, can i help you, but i need a screenshot in game (in concret the character taking the gun nd the Gun)

I didn’t follow that one because there is no description for it.

Nowhere in your code can I spot that you show Number_of_objects. So it looks like the numbers are not displayed because they’re hidden.

OP has given a link to a video of what happens.

Oh, the part of the code where it shows number of objects are in another part of the code that i didn’t show

So, can you include that in this thread?

Also, can you check that your Items all have an object variable named “quantity” that’s set to 1? Remember variable names are case sensitive.

Sr men
Is it possible that the “number of objects” is hidden by the command “Hide Number_Of_Objects” right? I understand that, as OP mentioned “It is so that numbers are NOT seen at the beginning of the scene”, but by not having a condition or not putting a condition with the purpose of revealing Number_Of_Objects, it remains permanently at 0?

I’m looking at your imgur image, command by command, this is a doubt of mine, since I still don’t use such complex commands being a relative newbie, so I want to ask you if it’s a typing error, or if it’s correct. In the command:


You put in “Inventory::Count” is this correct? Or is it “Inventory:Count”, sorry for asking one more question than helping, but I really try to contribute.

@ElementerTheDragon No, it is “Inventory::Count” and you can read about that here: Expressions [GDevelop wiki]. You should really read the documentation instead of making random guesses.

It is great that you want to contribute but to be honest pretty much none of your contributions that I have read over the last few days was in any way helpful to solve the problem. Instead of guessing you should be really sure that you have a solution. Additionally, using someone else’s thread to ask your own questions is neither helpful for browsing the forum for a possible solution nor is it respectful towards the OP.

That is correct, but OP comments with :

Yes, this is correct :

Doesn’t GDevelop automatically make variables just by mentioning a variable that doesn’t exist once? Maybe you need to make an event that actually changes the value of a scene/global/object variable so that it would actually make a variable.

Also sorry for being slow at replying

Yes, but it sets it to 0, false or empty string depending on it’s usage. You want it to be set to 1. Otherwise the following repeat block won’t action, and the item won’t get added to the inventory :

Also Quantity is a different variable to quantity.

No, set it in the editor as per the example. Don’t make extra, unnecessary work for yourself :

omg that was literaly all i had to do. thank you