Hello yet again! Managed to find myself another conundrum that I was hoping somebody could shed some light on.
This is a problem that's part of a somewhat convoluted system, so I'll try to focus only on the issue. Basically- I'm creating a save/load system for my game. It's strategy like, and set on a map which uses a few different arrays to store game info. I'm using the "AsJSON" expression to save the data into LocalStorage. Saving the game just writes these arrays to relevant keys, and loading pulls these keys back and loads the data back to the arrays.
This works great. However, I'm struggling to figure out how to handle loading the game's "Faction Units" arrays. This is an array that I use to store the information for each faction's units. On game start, I loop through the Faction Data array which stores the faction information and create a Faction Unit array for each faction, using the index as the connecting ID.
To be clear- there is only one Faction Data array, which has an entry for each faction, but a Faction Units array for each faction listed in the the former.
Creating and saving these arrays as keys is fine, as I can use a For Each X loop to create a key for each array instance, and use CurX to pick the relevant Faction Unit array and store the ID in the key name.
The problem lies in then loading these. I think the root of my issue is that loading is a two step process- you have to "get" the key, and on the separate "on found" trigger you can load the data to an array. But, I can't use the CurX expression in the "on found" trigger because of course it's separate from the loop. So I'm not sure how I'd go about reloading these arrays... this shows what I'm trying to do, obviously it does not work however:
Is there perhaps a different way I could do it? Any help would be hugely appreciated!