I just did it. Again, all array children turn from “empty” to “0”. It’s frustrating, I just hope I’m not frustrating you too much with this, petlimpet, thank you for helping me…
I just realised that you’re not refering to the children - sorry - im tired.
Array[number] …use square brackets
think of it like a chest of drawers - just need to refer to the right draw and not the chest
you need the square brackets in order to refer to the children of the array otherwise it’ll set the whole thing to zero
sorry - the red pen - looks a little shouty!
it’s not easy this stuff. I used to do a bit of this sort of thing when I was a young lad (many moons ago!) which probably helped prepare me for this hopelessly sad mid-life (‘mid’ is possibly a little generous) crisis that I appear to be going through. …im an artist …not a coder! coders like Keith know this and so im aware that my ways are possibly - not what a coder would do!
This is how I might do it. I used a button for testing bc I’m on my phone. It’s always best to check the button or key outside of a loop. That way the loop only runs when needed.
Trigger once doesn’t usually work as expected in loops. I added a boolean variable for 2 reasons. One to make sure only 1 item is changed and 2 to exit the loop when an item is found. There’s no sense in going any farther.
Things to remember with arrays. The first item is always zero. The count will always be 1 higher than the last item. So, if it was 10 items, it would be index 0 thru 9.
If you try to read the value of an index that doesn’t exist then it will create one using the default value like 0. Always be sure to check the count unless you know that it is always going to be the same.
@Keith_1357 and @petlimpet , thank you both for helping me! Your methods worked, I just needed to change the children in “Mock_Inventory_Item_Names” array from strings to numbers. It’s a pity array strings don’t work effectively (at least in GDevelop), but at least it worked!
Now I have the inventory system operating as intended (except when the inventory slots are full, but it’s something that could be fixed by, let’s say, preventing the player from opening a chest or acquiring a new item when the slots are completely full).
I just need a couple of days and I’ll have an example of it to share with you and everyone. Once again, thank you both for everything! I wouldn’t have achieved this without your help! For so long I struggled to create a game because I couldn’t make a working item inventory. It means a lot to me, I just can’t thank you enough for your help! ![]()
Once again, thank you for everything, @petlimpet ! I share your feelings, I’m also an artist (loosely speaking, of course), not exactly a coder. But I knew having an inventory system using arrays would’ve been more effective, specially when going across different scenes in the game.
I just wished to say that I’m sorry you’re passing through a mid-life crisis. Which is also something I share with you. It’s true we have hardships in life, like trying to solve an old, hard problem like it was my case here with the inventory system. But please, let me say this. No matter your age, there’s always time to achieve your dreams. And maybe acquire new ones too.
's true nowadays the world feels bleak and many wish to step on everyone to make us miserable, forever. That’s why we must fight for our dreams. To produce things to make others smile, to prove the world can be an amazing place to live.
You are not alone, @petlimpet , many share your feelings, so do not worry about anything, OK? Move your head up and smile. Look for things that will cheer you, take some good rest, and let the inspiration reach you once again. ![]()
Now the only thing left is to the change the topic’s title to [SOLVED]. I just can’t find the button to edit the title, sadly. I’m not sure if new users aren’t allowed to edit or it’s somewhere else…
Great …glad youve sorted it! Don’t worry about me…that’s just my sense of humour crawling out of its cage again. I’ve honestly got plenty to amuse myself with!
Yes …let’s fullfill our dreams! …I just like moving stuff around the screen! Honestly if you’d shown my younger self everything that’s possible in game dev these days …I just wouldn’t have believed it possible! What an extraordinary world we live in!
All the best!


