Adding a condition statement

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#61 Post by vangyver »

redline turns off and on with the switch but the digits stay on (L:FuseNavCom1)
Avionics and battery switches working correctly.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Adding a condition statement

#62 Post by Sling »

vangyver wrote: Mon Aug 16, 2021 7:23 am redline turns off and on with the switch but the digits stay on (L:FuseNavCom1)
Avionics and battery switches working correctly.
Did you get the latest code that fixed the small typo. BTW the redline turns on/off with the same variable as the digits so if one works they should both work. If you are still having problems we'll need to put that print back in so we can see what the inputs are doing in the console ouput.

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#63 Post by vangyver »

Git it. added ==1
--make a boolean power variable based on state of avionics, battery, generator and FuseNavCom1 == 1
local power = avionics >= 8 and (battery >= 8 or generator) and FuseNavCom1 == 1
img_visible(redline, power)

Thanks to all. Air Manager`s support team is FANTASTIC.

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#64 Post by vangyver »

Here is the final working code next. Works Great

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#65 Post by vangyver »

-- Add images in Z-order --
img_add_fullscreen("KX165A.png")
redline = img_add("redline.png", 364, 10, 2, 300)

-- Add text --
txt_com1 = txt_add(" ", "size:25px; color:#DCF509; halign:left", 25, 40, 200, 200)
txt_com1stby = txt_add(" ", "size:25px; color:#DCF509; halign:left", 200, 40, 200, 200)

txt_nav1 = txt_add(" ", "size:25px; color:#DCF509; halign:left", 365, 40, 200, 200)
txt_nav1stby = txt_add(" ", "size:25px; color:#DCF509; halign:left", 520, 40, 200, 200)

-- Set default visibility --
img_visible(redline, false)

--subscribe callback --
function new_navcomm_FSX(avionics, nav1, nav1stby, com1, com1stby, battery, generator, FuseNavCom1)

--make a boolean power variable based on state of avionics, battery, generator and FuseNavCom1 == 1
local power = avionics >= 8 and (battery >= 8 or generator) and FuseNavCom1 == 1
img_visible(redline, power)

if power then
txt_set(txt_com1, string.format("%06.02f",com1, com1%1) )
txt_set(txt_com1stby, string.format("%06.02f",com1stby, com1stby%1))
txt_set(txt_nav1, string.format("%06.02f",nav1, nav1%1))
txt_set(txt_nav1stby, string.format("%06.02f",nav1stby, nav1stby%1) )
else
txt_set(txt_com1, " ")
txt_set(txt_com1stby, " ")
txt_set(txt_nav1, " ")
txt_set(txt_nav1stby, " ")
end

end

--subscribes --
fsx_variable_subscribe("ELECTRICAL AVIONICS BUS VOLTAGE", "Volts",
"NAV ACTIVE FREQUENCY:1", "Mhz",
"NAV STANDBY FREQUENCY:1", "Mhz",
"COM ACTIVE FREQUENCY:1", "Mhz",
"COM STANDBY FREQUENCY:1", "Mhz",
"ELECTRICAL BATTERY BUS VOLTAGE", "Volts",
"GENERAL ENG GENERATOR SWITCH:1", "Bool",
"L:FuseNavCom1", "Enum", new_navcomm_FSX)

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Adding a condition statement

#66 Post by Sling »

vangyver,

Great news. We got there in the end. So glad its working as you wanted. Now back to my own projects. :D

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Adding a condition statement

#67 Post by Keith Baxter »

@Sling

Sorry quick OT question.

How did you like the dataref reset when testing?

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#68 Post by vangyver »

dataref reset ? I am very new at this.

vangyver
Posts: 127
Joined: Sat Dec 05, 2015 8:30 am

Re: Adding a condition statement

#69 Post by vangyver »

I can tell you this: I am lovin Air manager 4.02 with all the options of viewing the code / modifying the code / and seeing the results.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Adding a condition statement

#70 Post by Keith Baxter »

vangyver wrote: Mon Aug 16, 2021 8:01 am dataref reset ? I am very new at this.
Hi,

Corjan added a very nice feature to reset the dataref value to the sim value.

If you right click the send. I popup appears <reset to sim value> that if clicked will reset the dataref. Very handy when testing when multiple datarefs values need to be changed back and fourth.
ice_screenshot_20210816-100743.png

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply