Code: Select all
I have strip all the code from Sim Innovations generic radio module for the buttons and switches, and modified the PNG image to suit my needs. It works perfectly but I need to add a condition to the code - if avionics >= 1 and (battery >= 1 or generator[1] >= 1) then --
For the fsx_variable_subscribe I think I can add " L:Com1OnOff ", "Bool", or maybe something else?
Any help is greatly appreciated,
Vangyver
Code I am currently using:
-- 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(" ", "-fx-font-size:55px; -fx-fill: #DCF509; -fx-text-alignment: LEFT;", 25, 90, 200, 200)
txt_com1stby = txt_add(" ", "-fx-font-size:55px; -fx-fill: #DCF509; -fx-text-alignment: LEFT;", 200, 90, 200, 200)
txt_nav1 = txt_add(" ", "-fx-font-size:55px; -fx-fill: #DCF509; -fx-text-alignment: LEFT;", 365, 90, 200, 200)
txt_nav1stby = txt_add(" ", "-fx-font-size:55px; -fx-fill: #DCF509; -fx-text-alignment: LEFT;", 520, 90, 200, 200)
-- Set default visibility --
img_visible(redline, false)
-- Functions --
function new_navcomm(avionics, nav1, nav1stby, com1, com1stby, battery, generator)
img_visible(redline, avionics >= 1 and (battery >= 1 or generator[1] >= 1))
if avionics >= 1 and (battery >= 1 or generator[1] >= 1) 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
switch_set_state(switch_onoff, avionics > 0)
end
function new_navcomm_FSX(avionics, nav1, nav1stby, com1, com1stby, battery, generator)
if generator == true then
generator = 1
else
generator = 0
end
new_navcomm(avionics, nav1*100+0.01, nav1stby*100+0.01, com1*100+0.01, com1stby*100+0.01, battery, {generator})
end
-- Bus subscribe --
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", new_navcomm_FSX)