Hello all,
I am building an Air Manager panel for the Challenger 300.
I have struggled to use the switch function. I need a button that can turn the electrical batteries on and off. For some reason the switch function will not change the on / off images on the Air Manager side.
Could someone give me a simple switch script that works? If I can see something that works, it helps me a lot!
Thanks!
P.S. I am using X-Plane 11, MacOS.
Switch Function
Re: Switch Function
What’s wrong with the examples on the wiki. They should show you what you need.
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: Switch Function
Hi TKSim,
--DOME SWITCH
sw_DOME = switch_add("tog_mid.png","tog_down.png", 5,0,70,108,
function()
xpl_command("FJS/Q4XP/Switches/dome")
end)
----------------------------------------------------------------------------------------------------------
xpl_dataref_subscribe("FJS/Q4XP/Manips/TwoSwitch_Ctl", "INT[64]",
function (state)
switch_set_position(sw_DOME, state[21])
end)
The switch on the instrument tells X-Plane to execute a command, which changes a dataref value which is subscribed to which changes the graphics on the instrument via the switch_set_position statement.
It sounds like you are doing the first part, but not the second part.
I'm not sure how to explain it better than that, hope it helps.
Steve
--DOME SWITCH
sw_DOME = switch_add("tog_mid.png","tog_down.png", 5,0,70,108,
function()
xpl_command("FJS/Q4XP/Switches/dome")
end)
----------------------------------------------------------------------------------------------------------
xpl_dataref_subscribe("FJS/Q4XP/Manips/TwoSwitch_Ctl", "INT[64]",
function (state)
switch_set_position(sw_DOME, state[21])
end)
The switch on the instrument tells X-Plane to execute a command, which changes a dataref value which is subscribed to which changes the graphics on the instrument via the switch_set_position statement.
It sounds like you are doing the first part, but not the second part.
I'm not sure how to explain it better than that, hope it helps.
Steve
Re: Switch Function
The first step is to find a command or dataref that lets you set the switch position.
Re: Switch Function
Good info.
I did try that code. it changes the X-Plane side. But it still does not change AirManager's graphics.
The XPL command that I am using, is not an "on / off" position. it's just a toggle. Whichever position the Sim is at it will do the opposite.
my command is: "cl300/electrical/batt_left" as you can see, I can't turn it on or off. How would I use the switch function with that?
Thanks!
I did try that code. it changes the X-Plane side. But it still does not change AirManager's graphics.
The XPL command that I am using, is not an "on / off" position. it's just a toggle. Whichever position the Sim is at it will do the opposite.
my command is: "cl300/electrical/batt_left" as you can see, I can't turn it on or off. How would I use the switch function with that?
Thanks!
Re: Switch Function
If you just add xpl_command("cl300/electrical/batt_left") to a script and start the instrument, do you see it toggle in the simulator?
Re: Switch Function
Hi,
If the aircraft dev has done a good job with the aircraft then the status of this battery switch should be stored in either a standard or their own custom dataref. In that case you can have the AM switch in sync with the sim by following the preferred wiki example. If not then follow the alternative wiki example.
Hope that helps.
If the aircraft dev has done a good job with the aircraft then the status of this battery switch should be stored in either a standard or their own custom dataref. In that case you can have the AM switch in sync with the sim by following the preferred wiki example. If not then follow the alternative wiki example.
Hope that helps.
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: Switch Function
As Sling said, now figure out which dataref changes with the switch and what values it has for each position. It'll most probably be 0 and 1. It can be a pain to find sometimes 

Re: Switch Function
seems to be the main issue..................................................................................For some reason the switch function will not change the on / off images on the Air Manager side

Joe. CISSP, MSc.