(Solved)Inventory loading problem

Hello
i am having problem loading inventory in the order it was saved
it saves and loads but it doesn’t remembers the order of the item

If you want the order of the items preserved, save the order to local storage as part of the PlayerInventorysave structure - I’d suggest you add PlayerInventorysave.Item.order - and use that instead of a counter.

If you are using the most recent version of GDevelop, then here are a few notes about your events:

  • Instead of storing the temporary information in InventoryVariable.counter, InventoryVariable.Item & InventoryVariable.ItemName, consider using a local variable (declared it in the parent event)
  • You don’t need to use VariableString if the variable is already a string, and use ToString if it’s not.
  • That repeat for each instance of InventoryItemIndicator is pointless. There is only 1 InventoryItemIndicator that it will affect each time, the one with the same ID as InventoryVariabel.counter

If I use the local variable then will i able to use it in multiple scene because i have the inventory event in external events

Okay i tried to do it like the barn variables the way you told me but I just can’t replicate it

i tried using climb variable method but it just doesn’t loads
The only part i can’t understand is if i save then how can I make it load in the same order?

If those events are in an external event, then yes, you can use the local variables in the external events and they will work in which ever events sheet links to the external event.


Can you screen shot your save events?

i am saving like this

okay so i checked the debugger and the thing is that it doesn’t saves in the order
so maybe it’s not a loading problem

Correct. As I posted earlier, consider adding PlayerInventorysave.Item.order to the variable so that it is saved and loaded along with the item details. Then the order of the data in storage doesn’t matter.

Sorry i am a little confused

is this a variable i need to add or a command?
if yes then how should i use it to remember order?

So i followed the method you told me for the barn


i am able to create this for each inventory slot but i am not able to add the animation name or the count

Sorry, I can’t see where I wrote to do that.


Here’s what I’ve done that works. I set the ID of InventoryIndicator in the scene editor. The variables used to load and save the inventory are:


The load events (I'm creating the number object on the fly as that's the easiest way to link that and the inventoryIndicator objects):


And the save events (I used the "s" key, but you can use whatever conditions you need):

Thank you for the reply but i have solved it. I have used the same method

1 Like