Jump to content
The simFlight Network Forums

LUA: copy offset into Lvar


Recommended Posts

Hello,

What I am trying to do is to create Lvar that will contain a value from a FSUIPC offset. I need this in order to use this L:Var using Air Manager later on. 

I am tesing on simple dewpoint value:

 

while 1 do
dp = ipc.readSW("0E8E")
ipc.display("dew point from offset"..dp/256)
ipc.writeLvar("L:DEWPOINT", dp)
dpL = ipc.readLvar("L:DEWPOINT")
ipc.display("\n".."dew point from Lvar"..dpL)
ipc.sleep(50)
end

Which returns error into FSUIPC log "2651078 *** LUA Error: ...s (x86)\Steam\steamapps\common\FSX\Modules\Meteo.lua:9: attempt to concatenate global 'dpL' (a nil value)"

I am trying to .display both the values to check if the read and write is working. I will remove the display later on

Do I need to introduce the L:DEWPOINT var before? 

 

---------------------------------------------------------------------------------------------------------------------------------------------

while 1 do
dp = ipc.readSW("0E8E")
ipc.writeLvar("L:DEWPOINT", dp)
ipc.sleep(50)
end

With this minimalistic code there are no errors in the log, but the Air Manager seems to read "0.0" from L:DEWPOINT variable.

 

Thank you!

Pavel  

Link to comment
Share on other sites

You cannot create an lvar - they are provided by the aircraft guages. You can use the provided control (or lua script) to list available lvars for the loaded aircraft (see the user guide).

Why do you want to use an lvar anyway? If using in a lua script, use a global variable. You can also pass variables between scripts (see 

).

John

Link to comment
Share on other sites

46 minutes ago, Paja said:

Which returns error into FSUIPC log "2651078 *** LUA Error: ...s (x86)\Steam\steamapps\common\FSX\Modules\Meteo.lua:9: attempt to concatenate global 'dpL' (a nil value)"

If dpL is a nil value that will be because " ipc.readLvar("L:DEWPOINT")" found that L:DEWPOINT didn't exist. You can stop the error by checking whether dpL is nil before using it.

49 minutes ago, Paja said:

Do I need to introduce the L:DEWPOINT var before? 

If the L:Var does not exist, then you cannot write to it nor read from it. Check whether it exists by using the List L:Vars control.

53 minutes ago, Paja said:

What I am trying to do is to create Lvar that will contain a value from a FSUIPC offset

FSUIPC doesn't create L:Vars, it only provides facilities to read and write them.

Pete

 

 
Link to comment
Share on other sites

Just recently I needed to do the same thing, write to an L:Var that doesn't exist for AirManager .
Created a small gauge and installed it into the VC.
It just creates an L:Var by writing to once on load.

Roman

<Gauge Name="Maddog FGCP VS Mode Server" version="1.0">
	<Update>
        <!-- DO THIS JUST ONCE ON INITIAL GAUGE LOAD -->
		(G:Var1) 0 == if{ 100 (>L:VS_Mode, number) 0 (>L:VS_Mode, number) 1 (>G:Var1) } 
	</Update>
</Gauge>

  

  • Like 1
Link to comment
Share on other sites

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.