How to make ASOBO_GT_Anim_Code <ANIM_CODE> persistent?

What’s the formula for calculating the frame number that ends up here:

There is no formula for this.
I have a config file that is read in simconnect (before spawning anything in the sim) that looks like:
[item1]
val=1
[item2]
val=2
[item3]
val=3

and it populates the array [1,2,3]
(there is no order or pattern in the data, it is set through an external UI to tune the end result in then sim, but it is crucial that the nth spawned simobject in the sim use the corresponding nth item in the array)

then :

set L:VAR1 = someArrayToStoreMyData[n] (with SimConnect_SetDataOnSimObject())
simobject n is spawned,
reads L:VAR1 once
sets L:1:VAR to nth element of the array
use that as anim code

n++ in simconnect ← need to find a way to link this to after the current simobject was spawned and set its anim code.

repeat.

It looks like your simconnect app knows the lat/long of each simobject, that is something each simobject also knows. This is the KEY detail you need. You’d be better off using that information to allocate your frame numbers to each simobject. I.e. your simconnect code would:

set L:ZZZ_YES_I_HAVE_READ_THE_DATA = 0
set L:ZZZ_LAT = latitude of simobject you want to send data to
set L:ZZZ_LONG = longitude of simobject you want to send data to
set L:ZZZ_ANIM_FRAME = frame number you want that simobject to load

when ZZZ_YES_I_HAVE_READ_THE_DATA becomes 1, you know the given simobject has got the data and you can repeat the cycle for the next one.

and in the simobject XML:

if L:ZZZ_LAT & LONG == A:PLANE LATITUDE / A:PLANE LONGITUDE (with some rounding) then
copy L:ZZZ_ANIM_FRAME into O:ANIM_FRAME
set L:YES_I_HAVE_READ_THE_DATA = 1

and animate your feature with O:ANIM_FRAME

This is exactly what I’ve been trying to do but:

Since my simobjects are not the user aircraft they can’t set L:vars. That was my first try but I can’t make this work. setting L:1 vars woks fine but not L:vars. Or maybe I’m missing something that won’t let my objects set L:vars but I think this is the reason.

Thanks for the help but unless I can find a way to make my simobjects set L:vars this approach won’t work.

Apologies - I wasn’t aware of the scenery simobject not being able to set L:vars.

Given that, I think my least-worst option would be to omit the L:var write. Create all the scenery simobjects, and then have the simconnect code iterating at a half-second period updating the ZZZ_LAT/LONG/ANIM_CODE so the SimObjects pick that up without acknowledging by writing the L:Var. Alternatively you could iterate faster but iterate multiple times (the issue is simply to have confidence each SimObject picks up their update).

The fundamental idea remains the same, the Simconnect program is using the lat/long of each simobject as the shared piece of information known to Simconnect and unique to each SimObject.

I also tried that approach but it didn’t work either because:
The rate at which the objects spawn is highly dependent on the end user computer performance. I can’t really plan for that.
That what I meant by ‘kind of work’. Its not very reliable. Mileage vary depending on the number of objects to spawn. sometime if works sometime it doesn’t. If some long frames or lag happen during the process it messes things up.
I even get different results depending on if I use a debug or release build.