Hello Everybody and Thank you in advance for helping me.
Im new in Programming so I'd like to ask you how I can use a LVAR from the SIM to initialize a local variable in my code?
I want to use the LVAR S_FCU_EFIS1_BARO_STD as initial situation for my local variable "situacaobaro".
function tunix()
end
fs2020_variable_subscribe("L:S_FCU_EFIS1_BARO_STD","INT",tunix)
fs2020_variable_write("L:S_FCU_EFIS1_BARO_STD","INT", 0)
function barostd_callback()
situationbaro = i want to read the value of this SIM LVAR >>>>>L:S_FCU_EFIS1_BARO_STD<<<<<<<<<
if situationbaro == 0 then
fs2020_variable_write("L:S_FCU_EFIS1_BARO_STD","INT", 1)
else
fs2020_variable_write("L:S_FCU_EFIS1_BARO_STD","INT", 0)
end
end
Thank you once again,
Lucas Godoy
Use LVAR from the SIM to initialize Local Variable - Hardware Programming
-
- Posts: 3
- Joined: Wed Jan 18, 2023 1:35 pm
- Crunchmeister
- Posts: 222
- Joined: Tue Aug 10, 2021 2:06 pm
Re: Use LVAR from the SIM to initialize Local Variable - Hardware Programming
Declare a local variable for the value you want. With the callback function called by the subscription, pass the value you're subscribed to, and assign it to the local var within that function.
You can also do this for multiple vars with 1 function. Then those values will always be available in your script, and will get updated automatically to current value whenever they're changed in the sim.
Code: Select all
local myBaro
function tunix(val)
mybaro = val
end
fs2020_variable_subscribe("L:S_FCU_EFIS1_BARO_STD","INT",tunix)
Code: Select all
local myVar1
local myVar2
local myVar3
function setVars(val1, val2, val3)
myVar1 = val1
myVar2 = val2
myVar3 = val3
end
fs2020_variable_subscribe("lvar1", "type",
"lvar2", "type",
"lvar3", "type",
setVars)
- Ryzen 5950x, 64GB 3600MHz RAM, RTX3070Ti
Simstrumentation Instrument dev
Free Air Manager instruments for MSFS available at http://www.simstrumentation.com
Simstrumentation Instrument dev
Free Air Manager instruments for MSFS available at http://www.simstrumentation.com