I can’t for the life of me figure this one out and I’m hoping someone could help. I’m trying to refill a players backpack from their save file data.
I have the item names of their picked up items saved in an array called “InBackpack”. I need to copy those names to an object variable called “ItemHeld” for each one of those objects that exists.
How do I do this?
Pic of the array
Basically I want “Item1” from the array copied into the “ItemHeld” variable of the first object InvSlot on screen, "Item2 " for the next object on screen, and so on for each InvSlot on screen.
The problem with the approach you’ve taken is that you are iterating over each InvSlot, so the conditions of the subevent will only be working with that one InvSlot object. The order they’re processed in usually depends on the order they were created on the scene.
A better approach would be to iterate over each InBackPack item/child, find the empty InvSlot that’s nearest 0,360 and work with that.
However, seems I was wrong about the code above working, that puts the items back in the inventory slots. I can only get it to work as a sub event for “at beginning of scene”, however I need to place the extra inventory slots players can earn before filling them with items and they will not work as a sub event for the scene beginning because the screen doesn’t refresh (I suppose? like in the while loops) so it dumps all the slots at the same X,Y…
So, it only works if I give the items before the inventory slots are created… which fails as soon as I add more slots. A catch 22. I am grateful for any ideas. I need some sort of “run once a few moments after the scene starts” sort of trigger for the while loop or a new way to place the inventory slots that isn’t based on the last X,Y position of the newly created slot. Or a clever way to refresh the screen between each inventory creation so it can grab the latest X,Y