-- 17.02.17/AH Problem A2A Cessna C172 Alternator on CH Throttle Quadrant not working -- Found LUA Script in https://a2asimulations.com/forum/viewtopic.php?f=108&t=37894 -- but it doesn't work as toggle so I modified it -- Offsets 0x3102 / 0x3101 not used for A2A: FSUIPC internal memory for Alternator and Battery -- A2A C172: If Alternator switched on, Battery goes on to to avoid spikes -- (Battery without Alternator: ok, Alternator without Battery: not ok) -- 11.05.18/AH Changed for TT On/Off-Switches: ipcPARAM=1/2 -> On/Off, don't need Toggle part but left it for documentation -- -- This script can be mapped to Alternator Toggle Switch for A2A C172 Cessna -- ALTERNATOR = ipc.readLvar("L:Eng1_GeneratorSwitch") BATTERY = ipc.readLvar("L:Battery1Switch") -- -- Activate the following code for debugging this script: -- ipc.setdisplay(300,500,500,200) -- ipc.lineDisplay("ALT State on Entry:" .. ALTERNATOR,1) -- ipc.lineDisplay("BAT State on Entry:" .. BATTERY,2) -- -- -- Parm 1/2 : Alternator on/off (if "on", battery has to go "on" too) -- if ipcPARAM == 1 then -- Battery + Alternator switches both on if (BATTERY == 0) then ipc.writeLvar("L:Battery1Switch", 1) ipc.sleep(200) end ipc.writeLvar("L:Eng1_GeneratorSwitch", 1) return elseif ipcPARAM == 2 then -- Alternator switch off (battery switch untouched) ipc.writeLvar("L:Eng1_GeneratorSwitch", 0) return -- -- Parm 3 : Toggle Alternator on/off (and switch battery to "on" if alternator goes to "on") -- elseif ipcPARAM == 3 then if (ALTERNATOR == 0) then if (BATTERY == 0) then ipc.writeLvar("L:Battery1Switch", 1) ipc.sleep(100) end ipc.writeLvar("L:Eng1_GeneratorSwitch", 1) else ipc.writeLvar("L:Eng1_GeneratorSwitch", 0) end -- -- ipcPARAM not implemented -- else ipc.log("ipcPARAM " .. ipcPARAM .. " unhandled") end -- Just for debugging -- ALTERNATOR = ipc.readLvar("L:Eng1_GeneratorSwitch") -- BATTERY = ipc.readLvar("L:Battery1Switch") -- ipc.setdisplay(300,500,500,200) -- ipc.lineDisplay("ALT State on Exit:" .. ALTERNATOR,3) -- ipc.lineDisplay("BAT State on Exit:" .. BATTERY,4) -- ipc.sleep(5000) -- End of debugging