Delta14Sierra Posted November 3, 2011 Report Posted November 3, 2011 Below is an assortment of LUA scripts I have for assigning commands to the Beech Duke Turbine (as well as the Beech Duke B60) under LINDA. I started with the scripts that came with LINDA and have since added my own. With the scripts I have added, I have been able to get EVERY switch on the left sub-panel to work. Even if you do not use LINDA, you should be able to glean valuable info to write your own individual scripts for the RealAir Beech Duke. Because many of the commands are "toggles," it is important to have your mechanical switches in their DEFAULT starting positions. Since I start up Cold & Dark, all of my mechanical switches must be off, otherwise their subsequent functions will not represent what is going on in the cockpit. NOTE: Some of these scripts include lines for sending commands to various GoFlight modules. You will need to edit to suit your personal use. There are multiple hours behind some of these snippets of code, so enjoy! -- ################################ -- RealAir Duke Turbine specific functions -- ################################ -- ## Annunciators ############### function Annunciator_1_Test_On () ipc.writeLvar("L:DukeT_Annun_Test_1", 1) end function Annunciator_1_Test_Off () ipc.writeLvar("L:DukeT_Annun_Test_1", 0) end function Annunciator_2_Test_On () ipc.writeLvar("L:DukeT_Annun_Test_2", 1) end function Annunciator_2_Test_Off () ipc.writeLvar("L:DukeT_Annun_Test_2", 0) end function Annunciator_Test_On () ipc.writeLvar("L:Main_Annun_Test", 1) end function Annunciator_Test_Off () ipc.writeLvar("L:Main_Annun_Test", 0) end function Duke_Master_Warning_Reset () LVarSet = "L:MW_Reset" val = 0 if ipc.readLvar(LVarSet) == 0 then val = 1 end ipc.writeLvar(LVarSet, val) end -- ## Avionics ############### function Duke_Avionics_Master_On () ipc.control(66701, 1) -- Avionics Master Switch On 0x3103 gfd.SetBright(GF46,1,15) gfd.SetBright(GFMCP,0,15) ipc.set("AvionicsMaster", 1) end function Duke_Avionics_Master_Off () ipc.control(66701, 0) -- Avionics Master Switch Off 0x3103 gfd.SetBright(GF46,1,0) gfd.SetBright(GFMCP,0,0) ipc.set("AvionicsMaster", 0) end function Duke_Main_Inverter_On () Inverter = "L:Duke_Inverter_Switch" ipc.writeLvar(Inverter, 0) end function Duke_Standby_Inverter_On () Inverter = "L:Duke_Inverter_Switch" ipc.writeLvar(Inverter, 2) end function Duke_Inverter_Off () Inverter = "L:Duke_Inverter_Switch" ipc.writeLvar(Inverter, 1) end function Duke_Instruments_On () _sleep(200, 400) ipc.writeLvar("L:NavCom1_On", 0) _sleep(200, 400) ipc.writeLvar("L:NavCom2_On", 0) _sleep(200, 400) ipc.writeLvar("L:XPDR_State", 1) _sleep(200, 400) ipc.writeLvar("L:dukeGpsOn", 1) _sleep(200, 400) ipc.writeLvar("L:ADF_On_Switch", 1) _sleep(200, 400) ipc.writeLvar("L:DME_Switch", 1) -- DME On ipc.runlua("DME-Select", 1) value = "1 " .. ipc.readSTR("0C29", 5) -- Reads DME1 Distance gfd.SetDisplay(GF166, 2, 0, value) -- Displays DME1 Distance value = ipc.readSTR("0C2E", 5) -- Reads DME1 Speed gfd.SetDisplay(GF166, 2, 1, value) -- Displays DME1 Speed end function Duke_Instruments_Off () _sleep(200, 400) ipc.writeLvar("L:DME_Switch", 0) _sleep(200, 400) ipc.writeLvar("L:NavCom1_On", 1) _sleep(200, 400) ipc.writeLvar("L:NavCom2_On", 1) _sleep(200, 400) ipc.writeLvar("L:XPDR_State", 0) _sleep(200, 400) ipc.writeLvar("L:dukeGpsOn", 0) _sleep(200, 400) ipc.writeLvar("L:ADF_On_Switch", 0) end -- ## Electrics ##################################### function Toggle_Master_Battery () ipc.control(66241, 0) gfd.SetBright(GFMCP,0,0) if ipc.get("MasterBattery") == 0 then gfd.SetBright(GFLGT, 0, 15) ipc.set("MasterBattery", 1) elseif ipc.get("MasterBattery") == 1 then gfd.SetBright(GFLGT, 0, 0) ipc.set("MasterBattery", 0) end end function Duke_L_Ignition_Switch_On () ipc.writeLvar("L:ignSwL", 2) end function Duke_L_Ignition_Switch_Auto () ipc.writeLvar("L:ignSwL", 0) end function Duke_L_Ignition_Switch_Off () ipc.writeLvar("L:ignSwL", 1) end function Duke_R_Ignition_Switch_On () ipc.writeLvar("L:ignSwR", 2) end function Duke_R_Ignition_Switch_Auto () ipc.writeLvar("L:ignSwR", 0) end function Duke_R_Ignition_Switch_Off () ipc.writeLvar("L:ignSwR", 1) end -- Magnetos function Magneto_1_Off () ipc.sleep(250) ipc.writeUW("0892", 0) end function Magneto_1_R_On () ipc.writeUW("0892", 2) end function Magneto_1_L_On () ipc.writeUW("0892", 1) end function Magneto_1_Both () ipc.writeUW("0892", 3) end function Magneto_1_Start () ipc.writeUW("0892", 4) end function Magneto_2_Off () ipc.sleep(250) ipc.writeUW("092A", 0) end function Magneto_2_R_On () ipc.writeUW("092A", 2) end function Magneto_2_L_On () ipc.writeUW("092A", 1) end function Magneto_2_Both () ipc.writeUW("092A", 3) end function Magneto_2_Start () ipc.writeUW("092A", 4) end -- ignition function DukeT_Ignition_L_on () ipc.writeLvar("L:ignSwL", 2) DspShow ("IgnL", "On") end function DukeT_Ignition_R_on () ipc.writeLvar("L:ignSwR", 2) DspShow ("IgnR", "On") end function DukeT_Ignition_B_on () ipc.writeLvar("L:ignSwL", 2) ipc.writeLvar("L:ignSwR", 2) DspShow ("IgnB", "On") end function DukeT_Ignition_L_auto () ipc.writeLvar("L:ignSwL", 0) DspShow ("IgnL", "Auto") end function DukeT_Ignition_R_auto () ipc.writeLvar("L:ignSwR", 0) DspShow ("IgnR", "Auto") end function DukeT_Ignition_B_auto () ipc.writeLvar("L:ignSwL", 0) ipc.writeLvar("L:ignSwR", 0) DspShow ("IgnB", "Auto") end function DukeT_Ignition_L_off () ipc.writeLvar("L:ignSwL", 1) DspShow ("IgnL", "Off") end function DukeT_Ignition_R_off () ipc.writeLvar("L:ignSwR", 1) DspShow ("IgnR", "Off") end function DukeT_Ignition_B_off () ipc.writeLvar("L:ignSwL", 1) ipc.writeLvar("L:ignSwR", 1) DspShow ("IgnB", "Off") end -- generator function DukeT_Generator_L_on () ipc.writeSB("3b78", 1) DspShow ("GenL", "On") end function DukeT_Generator_R_on () ipc.writeSB("3ab8", 1) DspShow ("GenR", "On") end function DukeT_Generator_B_on () ipc.writeSB("3b78", 1) ipc.writeSB("3ab8", 1) DspShow ("GenB", "On") end function DukeT_Generator_L_off () ipc.writeSB("3b78", 0) DspShow ("GenL", "Off") end function DukeT_Generator_R_off () ipc.writeSB("3ab8", 0) DspShow ("GenR", "Off") end function DukeT_Generator_B_off () ipc.writeSB("3b78", 0) ipc.writeSB("3ab8", 0) DspShow ("GenB", "Off") end -- starter function DukeT_Starter_L_on () ipc.writeSB("0892", 1) DspShow ("SttL", "On") end function DukeT_Starter_L_off () ipc.writeSB("0892", 0) DspShow ("SttL", "Off") end function DukeT_Starter_R_on () ipc.writeSB("092a", 1) DspShow ("SttR", "On") end function DukeT_Starter_R_off () ipc.writeSB("092a", 0) DspShow ("SttR", "Off") end -- ## Lights ##################################### function Duke_Beacon_Lights () ipc.control(66239) end function Duke_Beacon_Recognition_Lights () ipc.control(66239) ipc.control(66377) end function Duke_Nav_Lights () ipc.control(66379) end function Duke_Nav_Strobe_Lights () ipc.control(66379) ipc.control(65560) end function Duke_L_R_Landing_Lights_On () ipc.control(66059, 1) ipc.sleep(500) ipc.control(66376, 1) end function Duke_L_R_Landing_Lights_Off () ipc.control(66060, 0) ipc.sleep(500) ipc.control(66376, 0) end -- Landing lights left toggle function DukeT_LandingLightsL_toggle () ipc.control(65751) end -- Landing lights right toggle function DukeT_LandingLightsR_toggle () ipc.control(66376) end -- cockpit lights toggle function DukeT_CockpitLights_toggle () ipc.control(66579) end -- ## Fuel ##################################### function Duke_L_Pump_1_On () ipc.writeLvar("fuelPumpL", 0) -- Select L Fuel Pump 1 ipc.control(66340) -- Toggle L Fuel Pump 1 end function Duke_L_Pump_1_Off () ipc.control(66340) -- Toggle L Fuel Pump 1 end function Duke_L_Pump_2_On () ipc.writeLvar("fuelPumpL", 2) -- Select L Fuel Pump 2 ipc.control(66340) -- Toggle L Fuel Pump 2 end function Duke_L_Pump_2_Off () ipc.control(66340) -- Toggle L Fuel Pump 2 end function Duke_R_Pump_1_On () ipc.writeLvar("fuelPumpR", 0) -- Select R Fuel Pump 1 ipc.control(66341) -- Toggle R Fuel Pump 1 end function Duke_R_Pump_1_Off () ipc.control(66341) -- Toggle R Fuel Pump 1 end function Duke_R_Pump_2_On () ipc.writeLvar("fuelPumpR", 2) -- Select R Fuel Pump 2 ipc.control(66341) -- Toggle R Fuel Pump 2 end function Duke_R_Pump_2_Off () ipc.control(66341) -- Toggle R Fuel Pump 2 end function Duke_Tank_Selector_L_On () ipc.writeLvar("L:Duke_Tank_Selector_L", 50) ipc.writeLvar("FUEL_SELECTOR_ALL") end function Duke_Tank_Selector_L_Crossfeed () ipc.writeLvar("L:Duke_Tank_Selector_L", 100) end function Duke_Tank_Selector_L_Off () ipc.sleep(250) ipc.writeLvar("L:Duke_Tank_Selector_L", 0) end function Duke_Tank_Selector_R_On () ipc.writeLvar("L:Duke_Tank_Selector_R", 50) ipc.writeLvar("FUEL_SELECTOR_ALL") end function Duke_Tank_Selector_R_Crossfeed () ipc.writeLvar("L:Duke_Tank_Selector_R", 100) end function Duke_Tank_Selector_R_Off () ipc.sleep(250) ipc.writeLvar("L:Duke_Tank_Selector_R", 0) end -- Fuel pump + valve ENG1 on (both engines) function DukeT_FuelPumpENG1_on () ipc.writeSB("3b98", 1) end function DukeT_FuelPumpENG1_off () ipc.writeSB("3b98", 0) end function DukeT_FuelPumpENG2_on () ipc.writeSB("3ad8", 1) end function DukeT_FuelPumpENG2_off () ipc.writeSB("3ad8", 0) end function DukeT_FuelValveENG1_on () ipc.writeLvar("L:Duke_Tank_Selector_L", 50) end function DukeT_FuelValveENG1_off () ipc.writeLvar("L:Duke_Tank_Selector_L", 0) end function DukeT_FuelValveENG2_on () ipc.writeLvar("L:Duke_Tank_Selector_R", 50) end function DukeT_FuelValveENG2_off () ipc.writeLvar("L:Duke_Tank_Selector_R", 0) end function DukeT_FuelPumps_on () ipc.writeSB("3b98", 1) ipc.writeSB("3ad8", 1) end function DukeT_FuelPumps_off () ipc.writeSB("3b98", 0) ipc.writeSB("3ad8", 0) end function DukeT_FuelValves_on () ipc.writeLvar("L:Duke_Tank_Selector_L", 50) ipc.writeLvar("L:Duke_Tank_Selector_R", 50) end function DukeT_FuelValves_off () ipc.writeLvar("L:Duke_Tank_Selector_L", 0) ipc.writeLvar("L:Duke_Tank_Selector_R", 0) end -- ## Cowl Flaps ##################################### function L_Cowl_Flap_Half () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 1) end function L_Cowl_Flap_Open () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 2) end function L_Cowl_Flap_Close () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 0) end function R_Cowl_Flap_Half () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 1) end function R_Cowl_Flap_Open () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 2) end function R_Cowl_Flap_Close () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 0) end -- oil cowl flaps closed function DukeT_Cowl_close () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 0) ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 0) DspShow ("Cowl", "clos") end -- oil cowl flaps half function DukeT_Cowl_half () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 1) ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 1) DspShow ("Cowl", "half") end -- oil cowl flaps open function DukeT_Cowl_open () ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", 2) ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", 2) DspShow ("Cowl", "open") end function CawlFlaps_LEFT_open () local buf = ipc.readLvar("L:Duke_Cowl_Flaps_Switch_1") + 1 if buf > 2 then buf = 2 end ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", buf) DspShow ("CowL", "open") end function CawlFlaps_LEFT_close () local buf = ipc.readLvar("L:Duke_Cowl_Flaps_Switch_1") - 1 if buf < 0 then buf = 0 end ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_1", buf) DspShow ("CowL", "clos") end function CawlFlaps_RIGHT_open () local buf = ipc.readLvar("L:Duke_Cowl_Flaps_Switch_2") + 1 if buf > 2 then buf = 2 end ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", buf) DspShow ("CowR", "open") end function CawlFlaps_RIGHT_close () local buf = ipc.readLvar("L:Duke_Cowl_Flaps_Switch_2") - 1 if buf < 0 then buf = 0 end ipc.writeLvar("L:Duke_Cowl_Flaps_Switch_2", buf) DspShow ("CowR", "clos") end function CawlFlaps_BOTH_open () CawlFlaps_LEFT_open () CawlFlaps_RIGHT_open () DspShow ("Cwls", "open") end function CawlFlaps_BOTH_close () CawlFlaps_LEFT_close () CawlFlaps_RIGHT_close () DspShow ("Cwls", "clos") end -- ## De-Ice ############### function Fuel_Vent_Heat_1_2_On () ipc.writeLvar("L:fuelVentHeatL", 1) ipc.sleep(500) ipc.writeLvar("L:fuelVentHeatR", 1) end function Fuel_Vent_Heat_1_2_Off () ipc.writeLvar("L:fuelVentHeatR", 0) ipc.sleep(500) ipc.writeLvar("L:fuelVentHeatL", 0) end function Duke_Surface_DeIce_One_Cycle () ipc.writeLvar("Duke_Surface_Deice", 0) end function Duke_Surface_DeIce_Manual () ipc.writeLvar("L:Duke_Surface_Deice", 2) end function Duke_Surface_DeIce_Off () ipc.writeLvar("L:Duke_Surface_Deice", 1) end function Structural_Deice_Toggle () ipc.writeLvar("L:TOGGLE_STRUCTURAL_DEICE") end function Duke_Pitot_Switches_L_R_On () ipc.control(66072) ipc.sleep(500) ipc.writeLvar("L:Stall_Heat", 1) end function Duke_Pitot_Switches_L_R_Off () ipc.writeLvar("L:Stall_Heat", 0) ipc.sleep(500) ipc.control(66073) end function Duke_Prop_Windshield_Heat_On () ipc.control(66338) ipc.sleep(500) ipc.writeLvar("L:Duke_Wshield_Heat", 1) end function Duke_Prop_Windshield_Heat_Off () ipc.writeLvar("L:Duke_Wshield_Heat", 0) ipc.sleep(500) ipc.control(66338) end function AntiIce_On () ipc.control(66029) end function AntiIce_Off () ipc.control(66030) end function AntiIce_Eng_1_2_Toggle () ipc.control(66484) ipc.sleep(500) ipc.control(66485) end -- ## Other ############### --Parking Brakes function Parking_Brakes_On () ipc.writeSW("0BC8",32767) end function Parking_Brakes_Off () ipc.writeSW("0BC8",0) end -- Pressure Dump function Pressure_Dump_On () -- ipc.writeLVar("L:pressureDumpSwitch", 1) ipc.control(66841, 1) -- Pressurization Dump Switch On ipc.writeUB("0328", 1) end function Pressure_Dump_Off () -- ipc.writeLVar("L:pressureDumpSwitch", 0) ipc.control(66841, 0) -- Pressurization Dump Switch Off ipc.writeUB("0328", 0) end -- Pressure Shutoff Levers 1 & 2 function Pressure_Shutoff_Lever1_On () -- ipc.writeLvar("L:pressAirShutoffLever1", 1) end function Pressure_Shutoff_Lever1_Off () -- ipc.writeLVar("L:pressAirShutoffLever1", 0) end function Pressure_Shutoff_Lever2_On () -- ipc.writeLVar("L:pressAirShutoffLever2", 1) end function Pressure_Shutoff_Lever2_Off () -- ipc.writeLVar("L:pressAirShutoffLever2", 0) end -- Gyro Pilot-Copilot function Gyro_Pilot_Copilot_On () -- ipc.writeLVar("L:Gyro_Pilot_Copilot", 1) end function Gyro_Pilot_Copilot_Off () -- ipc.writeLVar("L:Gyro_Pilot_Copilot", 0) end -- XPDR inc function DukeT_XPDR_inc () i = ipc.readLvar("L:XPDR_State") if i < 5 then ipc.writeLvar("L:XPDR_State", i+1) end if i == 5 then ipc.writeLvar("L:XPDR_State", 5) end end -- XPDR dec function DukeT_XPDR_dec () i = ipc.readLvar("L:XPDR_State") if i > 0 then ipc.writeLvar("L:XPDR_State", i-1) end if i == 0 then ipc.writeLvar("L:XPDR_State", 0) end end function Master_Warning_Reset () LVarSet = "L:MW_Reset" ipc.writeLvar(LVarSet, 1) DspShow("MSTR", "CLR") end function Yoke_Hide () LVarSet = "L:DukeYokeVis" ipc.writeLvar(LVarSet, 1) DspShow("YOKE", "OFF") end function Yoke_Show () LVarSet = "L:DukeYokeVis" ipc.writeLvar(LVarSet, 0) DspShow("YOKE", "ON") end function RXP_530_show () -- shift + 2 ipc.keypress(50,9) end function Reliability () ipc.writeUW("0372",50) end function Center_Ailerons_Rudder () ipc.control(65612) end function Refresh_Scenery () ipc.control(65562) end -- ## system ############### function InitVars () Yoke_Hide () end 1
rustam Posted October 19, 2015 Report Posted October 19, 2015 Thank you VERY much, Sir!!! I took the liberty to translate your LINDA script to "basic" Lua language since I don't use Linda with FSX. And it works pretty well! I hope you don't mind... :) Cheers, Rustam
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now