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.
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?
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.
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.
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 :