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

#51 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
img_visible(redline, power)

if power then
txt_set(txt_com1, string.format("%06.02f",com1/100, com1%100) )
txt_set(txt_com1stby, string.format("%06.02f",com1stby/100, com1stby%100))
txt_set(txt_nav1, string.format("%06.02f",nav1/100, nav1%100))
txt_set(txt_nav1stby, string.format("%06.02f",nav1stby/100, nav1stby%100) )
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
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Adding a condition statement

#52 Post by Keith Baxter »

Hi,

Tony, Also line 23....

No worries I see you fixed it.

Keith
Last edited by Keith Baxter on Mon Aug 16, 2021 6:55 am, edited 1 time in total.
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 

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

Re: Adding a condition statement

#53 Post by Sling »

There is a small typo in that script that i missed in my haste. I've corrected it now so please go back to my last post with the full code and use that.

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

Re: Adding a condition statement

#54 Post by vangyver »

YEA ~ SUCCESS !
Untitled-4.jpg

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

Re: Adding a condition statement

#55 Post by vangyver »

Thank You So Much,
Vangyver

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

Re: Adding a condition statement

#56 Post by Sling »

Keith Baxter wrote: Mon Aug 16, 2021 6:51 am Hi,

Tony, Also line 23....

com1 = 123.45

Keith
Yep a remnant of me testing i already got that one and corrected it but you must of grabbed it before i corrected. Anyhow it should all be good now.

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

Re: Adding a condition statement

#57 Post by Keith Baxter »

Sling wrote: Mon Aug 16, 2021 6:54 am
Keith Baxter wrote: Mon Aug 16, 2021 6:51 am Hi,

Tony, Also line 23....

com1 = 123.45

Keith
Yep a remnant of me testing i already got that one and corrected it but you must of grabbed it before i corrected. Anyhow it should all be good now.
Yup all good Tony.

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 

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

Re: Adding a condition statement

#58 Post by Sling »

vangyver,

You are almost there. There is still that small typo which will stop the new Fuse LVAR from working correctly. Please grab it again as i just posted.

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

Re: Adding a condition statement

#59 Post by vangyver »

Testing now with switch

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

Re: Adding a condition statement

#60 Post by Keith Baxter »

vangyver wrote: Mon Aug 16, 2021 7:13 am Testing now with switch
Hi,



For future code posting. There is a icon above </>.
ice_screenshot_20210816-091647.png
ice_screenshot_20210816-091647.png (7.86 KiB) Viewed 2552 times
If you click on that icon then the code boxes appear. Insert your code between the code boxes and your post will look like what Tony posted.



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