ark1320 Posted April 17 Report Posted April 17 Hi John, I am trying to use the code below to access the value of the Avar (A:CG PERCENT, percent), but is not working. It seems the Lvar (L:ac_MAC, percent) is not "created" as expected. I can't display the the value of mac in a window, and when I test it the value of mac is nil. And the Lvar does not show up in the FSUIPC7 Lvar list. The Avar is valid, I can view its value it in the Simvar tool. Am I forgetting something? Thanks, Al (FS2020, FSUIPC7 1.7.3) ipc.execCalcCode(" (A:CG PERCENT, percent) (>L:ac_MAC, percent) ") -- get Mean Academic Chord (MAC) ipc.sleep(500) -- time to create Lvar Lear_MAC mac = ipc.readLvar("L:ac_MAC")
ark1320 Posted April 17 Author Report Posted April 17 Update to the above, did some experimenting: If I start FS2020 and load the plane onto the runway, the above code does not work. If I then go back to the sim's main menu and reselect the plane and again load it onto the runway, the code works. If I start FS2020 and load the plane onto the runway, the above code does not work. But if after the code fails if I then open FSUIPC7 and click on WASM > Reload and List Lvars, the code works. So if there was a way to rerun (or reactivate) WASM with programmatically with Lua code, that would be a "work around". You could run the calcCode to 'create' the Lvar, and then reactivate WASM to make the Lvar known. BTW, as an aside, the Relist part of the WASM function to Reload and List Lvars does not seem to work. After activating that I have to then click on List Lvars to see the list. Thanks, Al
John Dowson Posted April 17 Report Posted April 17 Although the lvar will be crested in the sim, it won't yet be known to FSUIPC. After the execCalcCode call, you need to add a csll to ipc.reloadWASM(), then wait/sleep for 100ms or so for the updated lvar list to be received.
ark1320 Posted April 17 Author Report Posted April 17 12 minutes ago, John Dowson said: Although the lvar will be crested in the sim, it won't yet be known to FSUIPC. After the execCalcCode call, you need to add a csll to ipc.reloadWASM(), then wait/sleep for 100ms or so for the updated lvar list to be received. Excellent! I was not aware of that reload WASM function. Thanks very much! Al
John Dowson Posted April 18 Report Posted April 18 11 hours ago, ark1320 said: I was not aware of that reload WASM function. There are various WASM ini parameters that control scanning for new lvars, but this should only be done in the fist few minutes after aircraft load, as that is generally when all useful lvars will be created. If any lvars are created after this period, then you will need to request a WASM reload (via lua, the provided control or the Add-ons->WASM menu->Reload WASM item) for them to be known by FSUIPC. However if the lvars are specifically created by FSUIPC, either via using lua ipc.createLvar or via offset 0x0D70), then the new lvars will automatically be pushed out to all WASM clients (including FSUIPC) and so no reload is necessary, although a short delay will still be needed before the lvar becomes available. This does not apply if the lvar is created in an ad-hoc manner via executing calculator code as you are doing (although there is nothing wrong doing it this way). Just FYI. Cheers, John 1
ark1320 Posted Sunday at 01:37 AM Author Report Posted Sunday at 01:37 AM On 4/18/2025 at 1:59 AM, John Dowson said: There are various WASM ini parameters that control scanning for new lvars, but this should only be done in the fist few minutes after aircraft load, as that is generally when all useful lvars will be created. If any lvars are created after this period, then you will need to request a WASM reload (via lua, the provided control or the Add-ons->WASM menu->Reload WASM item) for them to be known by FSUIPC. However if the lvars are specifically created by FSUIPC, either via using lua ipc.createLvar or via offset 0x0D70), then the new lvars will automatically be pushed out to all WASM clients (including FSUIPC) and so no reload is necessary, although a short delay will still be needed before the lvar becomes available. This does not apply if the lvar is created in an ad-hoc manner via executing calculator code as you are doing (although there is nothing wrong doing it this way). Just FYI. Cheers, John Thanks for that info, John, very good to know. If you are creating the Lvar in order to read an Avar value, it seems you would still have to use calculator code to get the Avar value into the new Lvar. But then no WASM reload is needed. In my particular application I needed to read the value of 4 different Avars, so I used one long calculator code to do that and then followed up with one wasm reload. Al
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now