For those who might be interested, I have doscovered that ChatGPT is a genius at writing code for Air Manager instruments. And FAST!!
You can ask Chat GPT in “laymans” words what you need and it will write the code required to do the job faster than you can read this text.
You need to understand a little bit - so you can collaborate… (ie. have your Air Manager instrument editor open, try the code and tell ChatGPT what worked and what didn’t)
I got Chat GPT to solve one really tricky problem that took some trial and error, but here is an example of a few simple tasks that I did yesterday
I asked Chat GPT the following question,
“Please modify the following code so that the avionics master is one switch and remove avionics 2”
( I just copied and pasted the text from the Lua script into ChatGPT )
– BATTERY SWITCH
function bat_click_callback(position)
if batt1_pos == true then
fs2020_event(“BATTERY1_SET”, 0)
else
fs2020_event(“BATTERY1_SET”, 1)
end
end
bat_switch_id = switch_add(“master_off.png”, “master_on.png”,44,30, 93,200,bat_click_callback)
function cb_battery(sw_pos)
switch_set_position(bat_switch_id, sw_pos)
batt1_pos = sw_pos
end
fs2020_variable_subscribe(“ELECTRICAL MASTER BATTERY:1”, “Bool”, cb_battery)
– END BATTERY SWITCH
– AVIONICS
function avionics1_click(position)
if sw1_pos then
fs2020_variable_write(“A:CIRCUIT SWITCH ON:24”, “Enum”, 0)
else
fs2020_variable_write(“A:CIRCUIT SWITCH ON:24”, “Enum”, 1)
end
end
avion_1_switch_id = switch_add(“white_rock_off.png”, “white_rock_on.png”,141,52, 48,160, avionics1_click)
function avionics2_click(position)
if sw2_pos then
fs2020_variable_write(“A:CIRCUIT SWITCH ON:25”, “Enum”, 0)
else
fs2020_variable_write(“A:CIRCUIT SWITCH ON:25”, “Enum”, 1)
end
end
avion_2_switch_id = switch_add(“white_rock_off.png”, “white_rock_on.png”,188,52, 48,160, avionics2_click)
function cb_avionics(sw_1, sw_2)
sw1_pos = sw_1
sw2_pos = sw_2
switch_set_position(avion_1_switch_id, sw1_pos)
switch_set_position(avion_2_switch_id, sw2_pos)
end
fs2020_variable_subscribe(“AVIONICS MASTER SWITCH:1”, “Bool”,
“AVIONICS MASTER SWITCH:2”, “Bool”,
cb_avionics)
– END AVIONICS
ChatGPT shot back with this solution
I replied to ChatGPT:
"Thanks, that worked. Now please modify the code so that the avionics switch can be activated on the touch screen like the Battery switch. At the moment the screen switch can only activated via a physical switch in my cockpit.
ChartGPT replied:
Next I asked ChatGPT to Add a “click_sound.wav” sound to the Battery switch when pressed."
As quick as lightening Chat GPT replied:
All I did was copy the code written by ChatGPT and paste it into the scrip of the instrument I was editing in Air Manager, saved, then clicked “RUN” to test… (with the SIM running too).
Yseterday I also asked ChatGPT to write the code for a stand-alone switch to operate the ENGINE MASTER. It wrote the entire code from start to finish - with generic names for images that I need to insert.
So this is like WOW!!!.
And just for those who might say I am lazy, firstly, I don’t really care. Flying is my hobby, not writing code; but secondly, it actually DOES teach in the process, so I am learning.
Like having an expert tutor sitting in my cockpit for no charge.
Hope someone else might find this useful.
Cheers.
Fearless Swan