How to load inventory?

Yes all of that is correct
i think the the numbers are showing the object instance number but that is just a guess
about the player i only have 1 player but i do have chests

Did this change anything. If you’re still having issues, I think it would help if I looked at the whole project. Would you be willing to put the entire project folder onto a file share site and let me look at it? I’m not sure these little snippets back and forth are getting very far. I think I need to see the bigger picture. I’m still not sure how the objects are picked.

If not, that’s fine. I’ll still try to help.

How about posting the current version of the events for loading inventory. Is InventoryItemIndicator the image of the items.

Umm the thing is i am planning to release it on steam
these are all the events for inventory
inventoryitemindicator is the sprite with all the images for inventory item

IDI is the sprite with all the images of object which player can pick




I understand completely. Where is the part that loads the inventory from storage through the array? I just want to see how the images are being picked. Are they using the counter? Did changing Item.count to lower case change anything?

Edit: I was playing with my test project. I added it to GitHub as a different repository.

https://github.com/doug13579/gdevelop-inventroy-example-2024-2

Click an item to tween it a slot, I added buttons instead of just keys. It loads the inventory on start but it doesn’t save automatically. I should add it. But I haven’t yet.

Something my version was missing was it loaded the inventory from storage but never assigned it to the inventory system. It was only displaying it.

I’m still learning the inventory system as well. I know the basics but some of it is still new to me.

try me: (updated the link so it adjusted to to the width of the screen)
https://games.gdevelop-app.com/game-b80b0135-ffd9-46b3-9fa7-264fd89e9245/index.html

here



here is the picking
no it doesn’t changes anything

yeah there is not much tutorial available online

i tried your example it is not loading as well

I’ll check the files on Github but the online linked version seems to work. It doesn’t automatically save and if slots are deleted by clinking on them then the inventory doesn’t choose a blank one if you click load. That feature was just inserted to see what would happen if there wasn’t an empty slot. I’ll look at your recent screenshots and edit this post if I see anything.

Just a heads up. I noticed on my version, I wasn’t adding the string from the storage to the inventory system. It needs the variable version that has been converted from JSON. See my previous post if needed.

OK. Where it’s checking the ID object variable it’s checking if it’s a string with the value “counter”

It should be checking the number variable named ID for the scene variable named counter. The current version is checking for the literal text “counter” not the variable.

Since none of the IDs are “counter” nothing gets triggered.


now the loading is working!!
one problem though so the items that were in the inventory when loaded it just turns the animation to empty slot but as soon as the items are loaded it adds to the previous one
before loading

after loading

Sounds like you’re getting closer. I think the next step is to follow the sequence of events and make sure it only loads once, in the right order or maybe something isn’t being cleared. This is a more of bigger picture thing. I’m not sure I can help with this part. It sounds like an order of events and I’m only seeing snippets without context. I’ll look at the events again later and I’ll let you know if I see anything.

Okay
how can I empty the entire inventory (not the save) just whatever is currently in the inventory
i did saw the remove the object option but it only works for one object

I’ve seen people manually clear it by using a repeat item count times to remove it item by item. I tried giving the set inventory to a variable an empty string and it seems fine. There is a JavaScript clear method which would probably be the best choice. I’ve never tried using the inventory system in JavaScript. I might try. If I do. I’ll share my results. You could also put in a feature request for an inventory clear action. That would be the best overall solution.

Anyways, to pass it an empty string, use a string variable say named temp

Temp = “”
load inventory inventoryName from variable Temp

In this case the “” in Temp = “” are 2 quote characters with nothing in between them.

i think i am doing it wrong

I thought this part was working. You shouldn’t need to clear the inventory system by setting it to temp, loading the inventory from storage and set the it to the variable converted from JSON should work.

It should probably be checking if storage exists though. Otherwise it might use the default values or a previous value.

No that is working i am just trying to clear the inventory before loading so when loading the items it won’t add up

As long as there’s something in storage, it should overwrite it.

If the storage doesn’t exist then maybe it needs to be cleared and refreshed. IDK.

I am going to try to do it i have posted in feature request