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.
Any help is appreciated.
My InvSlot object variables.
My (poor) attempt so far.
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.
Ty for the help MrMen. I have it working now with the code seen below, but now I have a related but separate problem.
When I drop an item I need it to also clear the entry in the array. is it possible to remove an array child by its string value?
delete the first InBackpack child that matches Items.ObjectName()
Here is the working fetch code for anyone who may find it useful
It looks like you’ve already got the array tools extension installed, so use:
Thank you again, that worked wonderfully.
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
Here is a SS of the code in question.
The first part places the extra inventory slots in the backpack. The second part puts the items in the slots based on the array.
Have you considered doing it a different way? Give the InvSlots a unique ID (starting with 0) and then using that ID for the InBackPack array index?