Adding a condition statement
Re: Adding a condition statement
Very strange it works perfectly here. Can you post a screen shot showing the full code pane. You must have something else different.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Adding a condition statement
Ignore that last request i now see the error after inputting a frequency. I'll post back the solution.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Adding a condition statement
Code: Select all
img_add_fullscreen("KX165A.png")
redline = img_add("redline.png", 364, 10, 2, 300)
-- Add text --
txt_com1 = txt_add(" ", "size:55px; color:#DCF509; halign:left", 25, 90, 200, 200)
txt_com1stby = txt_add(" ", "size:55px; color:#DCF509; halign:left", 200, 90, 200, 200)
txt_nav1 = txt_add(" ", "size:55px; color:#DCF509; halign:left", 365, 90, 200, 200)
txt_nav1stby = txt_add(" ", "size:55px; color:#DCF509; halign:left", 520, 90, 200, 200)
-- Set default visibility --
img_visible(redline, false)
--subscribe callback --
function new_navcomm_FSX(avionics, nav1, nav1stby, com1, com1stby, battery, generator, FuseNavCom1)
print("A"..avionics.." "..battery, generator, FuseNavCom1)
--make a boolean power variable based on state of avionics, battery, generator and FuseNavCom1
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("%d.%.02d",com1/100, com1%100) )
txt_set(txt_com1stby, string.format("%d.%.02d",com1stby/100, com1stby%100))
txt_set(txt_nav1, string.format("%d.%.02d",nav1/100, nav1%100))
txt_set(txt_nav1stby, string.format("%d.%.02d",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)
Re: Adding a condition statement
Try this on lines 25 to 28. That should be it this time.
You may have to alter the text positioning slightly by altering the txt_add() function x and y values if the image is now a little off because there was a slight shift when the text functions changed.
Code: Select all
txt_set(txt_com1, string.format("%07.03f",com1/100, com1%100) )
txt_set(txt_com1stby, string.format("%07.03f",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) )
Last edited by Sling on Mon Aug 16, 2021 6:24 am, edited 1 time in total.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Adding a condition statement
Hi,
Yes Tony is correct. I was about to post the same.
This is the string formatting one should use.
http://siminnovations.com/wiki/index.ph ... formatting
Keith
Yes Tony is correct. I was about to post the same.
This is the string formatting one should use.
http://siminnovations.com/wiki/index.ph ... formatting
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
Re: Adding a condition statement
Famous last words. I also just realised that the font sizes went all different when that change came about so the font size needs reducing. I also notice that you don't have 8.33khz com frequency spacing enabled so the string formatting for the com's needs to be the same as the nav's. To make things easy I've posted the whole corrected code below. Adjust the text size to suit.
Code: Select all
-- 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
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)
Last edited by Sling on Mon Aug 16, 2021 6:50 am, edited 3 times in total.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Adding a condition statement
does not match freq.
Should I copy your last full script. I had to decrease font size to 25px
Should I copy your last full script. I had to decrease font size to 25px
Re: Adding a condition statement
Ok , copied last full script. Freq does not match. Adjust font size and position
Re: Adding a condition statement
Sorry this is taking a few iterations but we are working with P3D which i don't have and an aircraft i also don't have. It looks like A2A are using frequencies that don't require the divide by 100 so just remove the /100 like this.
Code: Select all
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) )
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D