Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello John,

Really appreciate your support. Many othe MSFS venues take days to repond. You always respond quickly even if the issue may not be tied directly to FSUIPC7.

I have two questions:

1. There are two methods to defining LVars I have found (there may be others). One is to define LVars in the system.cfg file [LocalVar.n] and their initial value. These LVars are persistent with the aircraft. Another method is to define an LVar in a .flt file in the same category as in the systems.cfg file (different formats) which is not persistent.

I defined the LVars used in the DA62 in the system.cfg file instead of in the Lua and seems to work well. I use an LVar in the apron.flt and hangar.flt to let the Lua know the aircraft is not on the runway. 

The question has to do with the timeing of loading the LVars along with the Lua. I test for nil or 0 using the ipc.readLvar from the Library (not on Apron). I then test for the value set in the apron.flt file. The vaule is never what is contained in the apron.flt file DA62L_Apron = 22 or the runway.flt file DA62L_Apron = 0. So far I have seen the vaues 622 and 135 from the LVar.

Are Lua executions initiated befor the LVars are loaded? If the flight is started, an immediate list of the LVars (from the console) contains the LVars defined in the .cfg or .flt files. After a few moments, the console list Lua shows the defined LVars and the correct values.

Is there a way to wait until the LVars are loaded with the correct initial values? Test that the load is complete? There are several discussions about LVars using Simconnect and C++ but no where else. I have asked the same question in the MSFS Forum and no answer after 5 days.

2. And do you know if an LVar and its value defined in the system.cfg file can be changed by the LVars entry in the .flt file. Or are they mutually exclusive (can't have the same LVar in both definitions).

Thanks as always

 

FSUIPC7.log

MSFS_Lua.lua

Posted
35 minutes ago, DaveSCUSA said:

Are Lua executions initiated befor the LVars are loaded?

Auto-ran luas (including ipcReady.lua) are started once the initial list of lvars/hvars have been received by FSUIPC (from the WASM). The only lua that is started earlier is the ipcInit.lua, started once FSUIPC7 is connected to the sim.

35 minutes ago, DaveSCUSA said:

If the flight is started, an immediate list of the LVars (from the console) does not contain the LVars defined in the .cfg or .flt files. After a few moments, the console list Lua shows the defined LVars and the correct values.

The WASM waits for LvarScanDelay seconds before scanning for lvars, and the default value is 5 seconds. After this, further scans are performed at a frequency of LvarScanFrequency, which defaults to -2 (i.e. minimum 2 seconds between scans) and if/when any new lvars are detected they are pushed out to FSUIPC7. Please see the Advanced User guide (page 51) for the details on these WASM ini parameters.

35 minutes ago, DaveSCUSA said:

Is there a way to wait until the LVars are loaded with the correct initial values? Test that the load is complete?

Lvars can be created at any point, and there is no way to know/determine when they have been created or the initial values set. And it is dependenat on the aircraft - for GA aircraft, a 5 second delay (from aircraft loaded to lvar scan) is usually enough, but for complex airliners it may take a lot longer, and in some aircraft lvars can be created several minutes after aircraft load. There is no way to test if the list is complete - it is never complete as lvars can be created at any time. If you know the lvars you want to use, then you just have to check for their availability in a loop, then continue once you have received a non-nil id.

35 minutes ago, DaveSCUSA said:

2. And do you know if an LVar and its value defined in the system.cfg file can be changed by the LVars entry in the .flt file. Or are they mutually exclusive (can't have the same LVar in both definitions).

No idea - I have never used these files. I thought an lvar is an lvar, regardless of how it is created.

I don't think creating these lvars via config files is a good idea...Why don't you just create them in am auto-started lua, and add checks in any lua script that uses them at the start of the script, e.g. something like

-- Check Lvar exists
while (ipc.getLvarId("L:myLvar") == nil)
do
  ipc.sleep(200) -- wait before checking again
end

-- Lvar now available - continue

John

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.