Jump to content
The simFlight Network Forums

PMDG J41 reworked LUA Script (4th Jan 2011)


guenseli

Recommended Posts

Hello,

first, sorry that I have to start a new topic, but I can't edit my other LUA Script post...

I have reworked my LUA Script for the PMDG J41.

There are some new features:

- some new functions implemented, e.g. ice switches (except eng ice), all lights (including ice obs and consp lights)

- all switches have their sounds now

- all switches are animated (e.g. ALT)

- all functions are in this LUA now - you don't need an additional Macro file!

and the best feature:

MCP Combo Users (using the FSUIPC VRInsight Mod) have now a synchosized Autopilot Display, means the values of the J41 Display are now also visible on the MCP Display!

All credits go to kosta!!!

(sometimes HDG or ALT is 1 degree or 100ft wrong, but all in all it works very good!

Maybe ist working for other VRInsight devices too, but I don't know - try it!)

Because of this complete new stuff, the disadvantage is, that you have to reassign your buttons.

Old LUA assignments will not work, I'm sorry!

Important!

I will not explain how to use this LUA Script, or how to use the "FSUIPC VRInsight Mod".

Everything you should need and know is in this forum here or better in the FSUIPC manuals!

Please read and you will understand!!!

Have fun!!!

Günter

Here is the list of all functions

-- 9 ALT sel

-- 10 ALT plus

-- 11 ALT plus fast

-- 12 ALT minus

-- 13 ALT minus fast

-- 14 ALT hold

--

-- 15 HDG inc

-- 16 HDG inc fast

-- 17 HDG dec

-- 18 HDG dec fast

-- 19 HDG

-- 20 HDG bug press

--

-- 25 VS inc

-- 26 VS dec

--

-- 30 CRS left press

--

-- 35 IAS Press

-- 36 IAS plus

-- 37 IAS plus fast

-- 38 IAS minus

-- 39 IAS minus fast

--

-- 50 NAV

-- 51 APR

-- 52 VS

-- 53 BC

-- 54 IAS

-- 55 STBY

--

-- 56 AP Trim Power Switch on

-- 57 AP Trim Power Switch off

-- 58 AP Master

-- 59 AP Master off

--

-- 70 LEFT Bearing CIRCLE Knob Minus

-- 71 LEFT Bearing CIRCLE Knob plus

-- 72 LEFT Bearing DIAMOND Knob Minus

-- 73 LEFT Bearing DIAMOND Knob plus

--

-- 75 EFIS FULL/Map

-- 76 EFIS TCAS

-- 77 EFIS GSPD/TTG

-- 78 EFIS ET

-- 79 EFIS V/L

-- 80 EFIS LNAV

--

-- 90 Pilot analog ADFVOR 1 Toggle

-- 91 Pilot analog ADFVOR 2 Toggle

-- 92 Pilot ADF1

-- 93 Pilot VOR1

-- 94 Pilot ADF2

-- 95 Pilot VOR2

--

-- 100 Panel flood light on

-- 101 Panel flood light off

-- 102 Panel flood light toggle

--

-- 103 Console lights ON

-- 104 Console lights Off

-- 105 Console lights toggle

--

-- 106 flightdeck flood light toggle

-- 107 BCN light toggle

--

-- 108 NAV Lights ON

-- 109 NAV Lights Off

-- 110 NAV Lights toggle

--

-- 111 STR light toggle

-- 112 Landing lights toggle

-- 113 Taxi light toggle

--

-- 114 Consp Lights ON

-- 115 Consp Lights Off

-- 116 Consp Lights toggle

--

-- 120 LEFT Battery switch TOGGLE

-- 121 RIGHT Battery switch TOGGLE

-- 122 BOTH Battery switch ON

-- 123 BOTH Battery switch OFF

--

-- 125 Left AVIONICS SWITCh TOGGLE

-- 126 Right AVIONICS SWITCh TOGGLE

-- 127 both AVIONICS SWITCh on

-- 128 both AVIONICS SWITCh off

--

-- 130 LEFT Generator SWITCH TOGGLE

-- 131 RIGHT Generator SWITCH TOGGLE

-- 132 LEFT Generator SWITCH on

-- 133 LEFT Generator SWITCH off

-- 134 RIGHT Generator SWITCH on

-- 135 RIGHT Generator SWITCH off

--

-- 136 Left fuel Pump on

-- 137 Left fuel Pump off

-- 138 Right fuel Pump on

-- 139 Right fuel Pump off

--

-- 140 Prop Sync Toggle

--

-- 145 Ground Spoiler switch on

-- 146 Ground Spoiler switch off

-- 147 Ground Spoiler switch toggle

--

-- 150 windshield deice on

-- 151 windshield deice off

-- 152 airdata deice on

-- 153 airdata deice off

-- 155 Prop deice short on

-- 156 Prop deice short off

-- 157 Prop deice long on

-- 158 CCT Auto Cycle Switch

--

-- 160 warning mute switch toggle

--

-- 165 TOCW test switch on

-- 166 TOCW test switch off

--

-- 170 Seatbelt on

-- 171 Seatbelt on

--

-- 172 no smoking on

-- 173 no smoking on

--

-- 176 engine 1 feather (LEFT)

-- 177 no engine feather

-- 178 engine 2 feather (RIGHT)

--

-- 180 select engine 1 (LEFT)

-- 181 select engine 2 (RIGHT)

-- 182 unselect engines

--

-- 185 Feathering and starting selected engine

-- 186 abort starting sequence (stop) for selected engine

-- 187 starting selected engine

--

-- 190 gust locks toggle

-- 195 APU (ground power) connection toggle

-- 198 yellow attention get switch

-- 200 Anti-Skid on

-- 201 Anti Skid off

-- 202 Anti Skid toggle

And here is the code (sorry, I can't attach a file here)

-- LUA Script for the PMDG J41
-- January, the 4th 2011
-- made by Guenter (Guenseli) Steiner
-- file is free for use; credits are always welcome
-- thanks to kosta and some other guys... of course Pete Dowson



-- 9 ALT sel
-- 10 ALT plus
-- 11 ALT plus fast
-- 12 ALT minus
-- 13 ALT minus fast
-- 14 ALT hold
--
-- 15 HDG inc
-- 16 HDG inc fast
-- 17 HDG dec
-- 18 HDG dec fast
-- 19 HDG
-- 20 HDG bug press
--
-- 25 VS inc
-- 26 VS dec
--
-- 30 CRS left press
--
-- 35 IAS Press
-- 36 IAS plus
-- 37 IAS plus fast
-- 38 IAS minus
-- 39 IAS minus fast
--
-- 50 NAV
-- 51 APR
-- 52 VS
-- 53 BC
-- 54 IAS
-- 55 STBY
--
-- 56 AP Trim Power Switch on
-- 57 AP Trim Power Switch off
-- 58 AP Master
-- 59 AP Master off
--
-- 70 LEFT Bearing CIRCLE Knob Minus
-- 71 LEFT Bearing CIRCLE Knob plus
-- 72 LEFT Bearing DIAMOND Knob Minus
-- 73 LEFT Bearing DIAMOND Knob plus
--
-- 75 EFIS FULL/Map
-- 76 EFIS TCAS
-- 77 EFIS GSPD/TTG
-- 78 EFIS ET
-- 79 EFIS V/L
-- 80 EFIS LNAV
--
-- 90 Pilot analog ADFVOR 1 Toggle
-- 91 Pilot analog ADFVOR 2 Toggle
-- 92 Pilot ADF1
-- 93 Pilot VOR1
-- 94 Pilot ADF2
-- 95 Pilot VOR2
--
-- 100 Panel flood light on
-- 101 Panel flood light off
-- 102 Panel flood light toggle
--
-- 103 Console lights ON
-- 104 Console lights Off
-- 105 Console lights toggle
--
-- 106 flightdeck flood light toggle
-- 107 BCN light toggle
--
-- 108 NAV Lights ON
-- 109 NAV Lights Off
-- 110 NAV Lights toggle
--
-- 111 STR light toggle
-- 112 Landing lights toggle
-- 113 Taxi light toggle
--
-- 114 Consp Lights ON
-- 115 Consp Lights Off
-- 116 Consp Lights toggle
--
-- 120 LEFT Battery switch TOGGLE
-- 121 RIGHT Battery switch TOGGLE
-- 122 BOTH Battery switch ON
-- 123 BOTH Battery switch OFF
--
-- 125 Left AVIONICS SWITCh TOGGLE
-- 126 Right AVIONICS SWITCh TOGGLE
-- 127 both AVIONICS SWITCh on
-- 128 both AVIONICS SWITCh off
--
-- 130 LEFT Generator SWITCH TOGGLE
-- 131 RIGHT Generator SWITCH TOGGLE
-- 132 LEFT Generator SWITCH on
-- 133 LEFT Generator SWITCH off
-- 134 RIGHT Generator SWITCH on
-- 135 RIGHT Generator SWITCH off
--
-- 136 Left fuel Pump on
-- 137 Left fuel Pump off
-- 138 Right fuel Pump on
-- 139 Right fuel Pump off
--
-- 140 Prop Sync Toggle
--
-- 145 Ground Spoiler switch on
-- 146 Ground Spoiler switch off
-- 147 Ground Spoiler switch toggle
--
-- 150 windshield deice on
-- 151 windshield deice off
-- 152 airdata deice on
-- 153 airdata deice off
-- 155 Prop deice short on
-- 156 Prop deice short off
-- 157 Prop deice long on
-- 158 CCT Auto Cycle Switch
--
-- 160 warning mute switch toggle
--
-- 165 TOCW test switch on
-- 166 TOCW test switch off
--
-- 170 Seatbelt on
-- 171 Seatbelt on
--
-- 172 no smoking on
-- 173 no smoking on
--
-- 176 engine 1 feather (LEFT)
-- 177 no engine feather
-- 178 engine 2 feather (RIGHT)
--
-- 180 select engine 1 (LEFT)
-- 181 select engine 2 (RIGHT)
-- 182 unselect engines
--
-- 185 Feathering and starting selected engine
-- 186 abort starting sequence (stop) for selected engine
-- 187 starting selected engine
--
-- 190 gust locks toggle
-- 195 APU (ground power) connection toggle
-- 198 yellow attention get switch
-- 200 Anti-Skid on
-- 201 Anti Skid off
-- 202 Anti Skid toggle


-------------------------------------------------------------------------------
-- you should delete this part BELOW the lines if you don't use a VRInsight device
-------------------------------------------------------------------------------

if VRImodel == nil then
  VRIdevice = "COM3" 
  VRIdriver = "COM2"
end


speed = 115200 
handshake = 0  
minsize = 8
maxsize = 8     


dev = com.open(VRIdevice, speed, handshake)

if dev == 0 then
   ipc.log("Could not open VRIdevice port")
        ipc.display("Could not open VRIdevice port")
        ipc.sleep(1000)
end

-------------------------------------------------------------------------------
-- you should delete this part ABOVE the lines if you don't use a VRInsight device
-------------------------------------------------------------------------------


--ipc.display("test start")
--ipc.sleep(100)

--ipc.display("VRIdevice COM".. VRIdevice.. "\nVRIdriver COM".. VRIdriver.. "\nipcPARAM".. ipcPARAM)
--ipc.sleep(1000)







------------------------------------------------------------AP ALT

-- ALT sel

if ipcPARAM == 9 then

                ipc.writeLvar("L:FdModeselAltselSwitch", 1)
                ipc.control(66587,282)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselAltselSwitch", 0)
                ipc.control(66587,8031)


-- ALT plus

elseif ipcPARAM == 10 then

                Var = ipc.readLvar("IrcAltSelKnob")
                if Var >= 100 then 
                Var = 1
                end
                ipc.writeLvar("IrcAltSelKnob", Var+1)

                ipc.control(66587,3921)

                ipc.control(66587,8031)



-- ALT plus fast
elseif ipcPARAM == 11 then

                Var = ipc.readLvar("IrcAltSelKnob")
                if Var >= 100 then 
                Var = 1
                end
                ipc.writeLvar("IrcAltSelKnob", Var+5)


                for n=1, 10, 1 do
                ipc.control(66587,3921)
                end
                ipc.control(66587,8031)




-- ALT minus

elseif ipcPARAM == 12 then



                Var = ipc.readLvar("IrcAltSelKnob")
                if Var <= 1 then 
                Var = 100
                end
                ipc.writeLvar("IrcAltSelKnob", Var-1)

                ipc.control(66587,3920)
                ipc.control(66587,8031)




-- ALT minus fast

elseif ipcPARAM == 13 then

                Var = ipc.readLvar("IrcAltSelKnob")
                if Var <= 1 then 
                Var = 100
                end
                ipc.writeLvar("IrcAltSelKnob", Var-5)

                for n=1, 10, 1 do
                ipc.control(66587,3920)
                end
                ipc.control(66587,8031)


-- ALT hold

elseif ipcPARAM == 14 then

                ipc.writeLvar("L:FdModeselAltSwitch", 1)
                ipc.control(66587,281)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselAltSwitch", 0)
                ipc.control(66587,8031)

------------------------------------------------------------AP HDG
-- HDG plus

elseif ipcPARAM == 15 then


                ipc.control(66587,26902)

                ipc.control(66587,8031)




-- HDG plus fast

elseif ipcPARAM == 16 then

                for n=1, 10, 1 do
                ipc.control(66587,26902)
                end

                ipc.control(66587,8031)



-- HDG minus

elseif ipcPARAM == 17 then


                ipc.control(66587,26901)

                ipc.control(66587,8031)



-- HDG minus fast

elseif ipcPARAM == 18 then

                for n=1, 10, 1 do
                ipc.control(66587,26901)
                end

                ipc.control(66587,8031)



-- HDG 

elseif ipcPARAM == 19 then

                ipc.writeLvar("L:FdModeselHdgSwitch", 1)
                ipc.control(66587,277)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselHdgSwitch", 0)
                ipc.control(66587,8031)

-- HDG bug press

elseif ipcPARAM == 20 then

                ipc.writeLvar("L:IrcHdgKnobPush", 1)            
                ipc.control(66587,2691)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:IrcHdgKnobPush", 0)
                ipc.control(66587,8031)


------------------------------------------------------------


-- VS inc

elseif ipcPARAM == 25 then
                buffer = ipc.readLvar("L:VSIASTarget")

                Var = ipc.readLvar("L:AP_PitchWheel")


                ipc.writeLvar("AP_PitchWheel", Var+10)


                ipc.writeLvar("L:VSIASTarget", buffer+100)
                ipc.control(65894)
                ipc.control(66587,8031)




                buffer = ipc.readLvar("L:VSIASTarget")


                com.write(dev, string.format("DSP_%04d", buffer), 8)


-- VS dec

elseif ipcPARAM == 26 then
                buffer = ipc.readLvar("L:VSIASTarget")

                Var = ipc.readLvar("L:AP_PitchWheel")


                ipc.writeLvar("AP_PitchWheel", Var-10)


                ipc.writeLvar("L:VSIASTarget", buffer-100)
                ipc.control(65895)
                ipc.control(66587,8031)




                buffer = ipc.readLvar("L:VSIASTarget")


                com.write(dev, string.format("DSP_%04d", buffer), 8)


-- CRS press

elseif ipcPARAM == 30 then

                ipc.writeLvar("L:LeftIrcCrsKnobPush", 1)
                ipc.control(66587,2671)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:LeftIrcCrsKnobPush", 0)
                ipc.control(66587,8031)


-- IAS knob press

elseif ipcPARAM == 35 then

                ipc.writeLvar("L:IrcIasKnobPush", 1)
                ipc.control(66587,2681)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:IrcIasKnobPush", 0)
                ipc.control(66587,8031)


-- IAS plus 

elseif ipcPARAM == 36 then


                ipc.control(66587,26802)

                ipc.control(66587,8031)

-- IAS plus fast

elseif ipcPARAM == 37 then

                for n=1, 10, 1 do
                ipc.control(66587,26802)
                end

                ipc.control(66587,8031)

-- IAS minus

elseif ipcPARAM == 38 then


                ipc.control(66587,26801)

                ipc.control(66587,8031)

-- IAS minus fast

elseif ipcPARAM == 39 then

                for n=1, 10, 1 do
                ipc.control(66587,26801)
                end

                ipc.control(66587,8031)


------------------------------------------------------------ AP Mode select
-- NAV 

elseif ipcPARAM == 50 then

                ipc.writeLvar("L:FdModeselNavSwitch", 1)
                ipc.control(66587,278)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselNavSwitch", 0)
                ipc.control(66587,8031)

-- APR

elseif ipcPARAM == 51 then

                ipc.writeLvar("L:FdModeselAprSwitch", 1)
                ipc.control(66587,279)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselAprSwitch", 0)
                ipc.control(66587,8031)

-- VS

elseif ipcPARAM == 52 then

                ipc.writeLvar("L:FdModeselVsSwitch", 1)
                ipc.control(66587,283)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselVsSwitch", 0)
                ipc.control(66587,8031)

-- BC

elseif ipcPARAM == 53 then

                ipc.writeLvar("L:FdModeselBcSwitch", 1)
                ipc.control(66587,280)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselBcSwitch", 0)

                ipc.control(66587,8031)
-- IAS

elseif ipcPARAM == 54 then

                ipc.writeLvar("L:FdModeselIasSwitch", 1)
                ipc.control(66587,284)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselIasSwitch", 0)
                ipc.control(66587,8031)

-- STBY

elseif ipcPARAM == 55 then

                ipc.writeLvar("L:FdModeselSbySwitch", 1)
                ipc.control(66587,2851)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.writeLvar("L:FdModeselSbySwitch", 0)
                ipc.control(66587,2850)
                ipc.control(66587,8031)

-- AP Trim Power Switch on
elseif ipcPARAM == 56 then

                ipc.writeLvar("L:ApTrimPowerSwitch", 1)
                ipc.control(66587,8034)



-- AP Trim Power Switch off
elseif ipcPARAM == 57 then

                ipc.writeLvar("L:ApTrimPowerSwitch", 0)
                ipc.control(66587,8034)


-- AP Master
elseif ipcPARAM == 58 then

                ipc.writeLvar("L:APEngageSwitchSelect", 1)
                ipc.control(65580)
                ipc.control(66587,8038)
                ipc.sleep(200)
                ipc.writeLvar("L:APEngageSwitchSelect", 0)
                ipc.control(66587,8038)

-- AP Master off
elseif ipcPARAM == 59 then

                ipc.writeLvar("L:APEngageSwitchSelect", 1)
                ipc.control(65791)
                ipc.control(66587,8038)
                ipc.sleep(200)
                ipc.writeLvar("L:APEngageSwitchSelect", 0)
                ipc.control(66587,8038)


------------------------------------------------------------ EFIS BRG1 and BRG2

-- LEFT Bearing CIRCLE Knob Minus
elseif ipcPARAM == 70 then

        i = ipc.readLvar("L:LeftBearingCircleKnob")

        if i < 3 then
        ipc.writeLvar("L:LeftBearingCircleKnob", i+1)
        ipc.sleep(10)
        ipc.control(66587, 8031)
        end

        if i == 3 then
        ipc.writeLvar("L:LeftBearingCircleKnob", 3)

        end


-- LEFT Bearing CIRLCE Knob Plus
elseif ipcPARAM == 71 then

        i = ipc.readLvar("L:LeftBearingCircleKnob")

        if i > 0 then
        ipc.writeLvar("L:LeftBearingCircleKnob", i-1)
        ipc.sleep(10)
        ipc.control(66587, 8031)
        end

        if i == 0 then
        ipc.writeLvar("L:LeftBearingCircleKnob", 0)

        end


-- LEFT Bearing DIAMOND Knob Minus
elseif ipcPARAM == 72 then

        i = ipc.readLvar("L:LeftBearingDiamondKnob")

        if i > 0 then
        ipc.writeLvar("L:LeftBearingDiamondKnob", i-1)
        ipc.sleep(10)
        ipc.control(66587, 8031)
        end

        if i == 0 then
        ipc.writeLvar("L:LeftBearingDiamondKnob", 0)

        end     


-- LEFT Bearing DIAMOND Knob Plus
elseif ipcPARAM == 73 then

        i = ipc.readLvar("L:LeftBearingDiamondKnob")

        if i < 3 then
        ipc.writeLvar("L:LeftBearingDiamondKnob", i+1)
        ipc.sleep(10)
        ipc.control(66587, 8031)
        end

        if i == 3 then
        ipc.writeLvar("L:LeftBearingDiamondKnob", 3)

        end


------------------------------------------------------------ EFIS
-- Full/Map 

elseif ipcPARAM == 75 then

                ipc.control(66587,214)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)


-- TCAS 

elseif ipcPARAM == 76 then

                ipc.control(66587,215)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)


-- GSPD/TTG 

elseif ipcPARAM == 77 then

                ipc.control(66587,217)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)

-- ET

elseif ipcPARAM == 78 then

                ipc.control(66587,218)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)


-- V/L 

elseif ipcPARAM == 79 then

                ipc.control(66587,21901)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)


-- LNAV 

elseif ipcPARAM == 80 then

                ipc.control(66587,21910)
                ipc.control(66587,8031)
                ipc.sleep(200)
                ipc.control(66587,8031)

------------------------------------------------------------ Pilot analog VOR/ADF


-- Pilot analog ADFVOR 1 Toggle
elseif ipcPARAM == 90 then   


        LVarSet = "L:LeftAdfVorSwitch"
        val = 1

        if ipc.readLvar(LVarSet) == 1  then
        val = 2
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8024)





-- Pilot analog ADFVOR 2 Toggle
elseif ipcPARAM == 91 then

        LVarSet = "L:LeftVorAdfSwitch"
        val = 1

        if ipc.readLvar(LVarSet) == 1  then
        val = 2
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8024)





-- Pilot ADF1 
elseif ipcPARAM == 92 then

        ipc.writeLvar("L:LeftAdfVorSwitch", 0)
        ipc.control(66587, 8024)





-- Pilot VOR1
elseif ipcPARAM == 93 then

        ipc.writeLvar("L:LeftAdfVorSwitch", 1)
        ipc.control(66587, 8024)





-- Pilot ADF2
elseif ipcPARAM == 94 then

        ipc.writeLvar("L:LeftVorAdfSwitch", 1)
        ipc.control(66587, 8024)





-- Pilot VOR2
elseif ipcPARAM == 95 then

        ipc.writeLvar("L:LeftVorAdfSwitch", 0)
        ipc.control(66587, 8024)


------------------------------------------------------------ Lights

-- Panel flood light on
elseif ipcPARAM == 100 then

        ipc.writeLvar("L:PanelFloodSW", 1)
        ipc.control(66587, 8029)


-- Panel flood light off
elseif ipcPARAM == 101 then

        ipc.writeLvar("L:PanelFloodSW", 0)
        ipc.control(66587, 8029)


-- Panel flood light toggle
elseif ipcPARAM == 102 then
        LVarSet = "L:PanelFloodSW"
        val = 0

        if ipc.readLvar(LVarSet) == 0 then
        val = 1
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8029)


----------------------------------------------
-- Console lights ON
elseif ipcPARAM == 103 then

        ipc.control(66056)
        ipc.writeLvar("L:InstrConsolesLightSwitch", 1)
        ipc.writeLvar("L:InstrRoofLightSwitch", 1)
        ipc.writeLvar("L:InstrGlareshieldLightSwitch", 1)
        ipc.control(66587, 8031)


-- Console lights OFF
elseif ipcPARAM == 104 then

        ipc.control(66057)
        ipc.writeLvar("L:InstrConsolesLightSwitch", 0)
        ipc.writeLvar("L:InstrRoofLightSwitch", 0)
        ipc.writeLvar("L:InstrGlareshieldLightSwitch", 0)
        ipc.control(66587, 8031)


-- Console lights toggle
elseif ipcPARAM == 105 then

        val = 0
        val2 = 66057
        if ipc.readLvar("L:InstrConsolesLightSwitch") == 0 then
        val = 1
        val2 = 66056
                end
        ipc.control(val2)
        ipc.writeLvar("L:InstrConsolesLightSwitch", val)
        ipc.writeLvar("L:InstrRoofLightSwitch", val)
        ipc.writeLvar("L:InstrGlareshieldLightSwitch", val)
        ipc.control(66587, 8031)


-- flightdeck flood light toggle
elseif ipcPARAM == 106 then
        ipc.control(66376)
        ipc.control(66587,8027)


-- BCN light toggle
elseif ipcPARAM == 107 then
        ipc.control(66239)
        ipc.control(66587,8027)



-- NAV Lights ON
elseif ipcPARAM == 108 then

        ipc.writeLvar("L:NavLightSwitch", 2)
        ipc.control(66587, 8028)

-- NAV Lights Off
elseif ipcPARAM == 109 then

        ipc.writeLvar("L:NavLightSwitch", 1)
        ipc.control(66587, 8027)

-- NAV light toggle
elseif ipcPARAM == 110 then
        LVarSet = "L:NavLightSwitch"
        val = 1
        val2 = 8027
        if ipc.readLvar(LVarSet) == 1 then
        val = 2
        val2 = 8028
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, val2)


-- STR light toggle
elseif ipcPARAM == 111 then
        ipc.control(65560)
        ipc.control(66587,8028)


-- Landing lights toggle
elseif ipcPARAM == 112 then
        ipc.control(65751)
        ipc.control(66587,8027)


-- Taxi light toggle
elseif ipcPARAM == 113 then
        ipc.control(66240)
        ipc.control(66587,8028)



-- Consp Lights ON
elseif ipcPARAM == 114 then

        ipc.writeLvar("L:ConspicLight", 1)
        ipc.control(66587, 8028)
        ipc.control(66377)

-- Consp Lights Off
elseif ipcPARAM == 115 then

        ipc.writeLvar("L:ConspicLight", 0)
        ipc.control(66587, 8027)
        ipc.control(66377)

-- Consp light toggle
elseif ipcPARAM == 116 then
        LVarSet = "L:ConspicLight"
        val = 0
        val2 = 8027
        if ipc.readLvar(LVarSet) == 0 then
        val = 1
        val2 = 8028
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, val2)
        ipc.control(66377)

------------------------------------------------------------ Battery

-- LEFT Battery switch TOGGLE
elseif ipcPARAM == 120 then   


        LVarSet = "L:LeftBatSwitch"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8028)


-- RIGHT Battery switch TOGGLE
elseif ipcPARAM == 121 then


        LVarSet = "L:RightBatSwitch"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8028)



-- BOTH Battery switch on
elseif ipcPARAM == 122 then


        ipc.writeLvar("L:RightBatSwitch", 1)
        ipc.control(66587, 8028)
        ipc.sleep(250)
        ipc.writeLvar("L:LeftBatSwitch", 1)
        ipc.control(66587, 8028)


-- BOTH Battery switch off
elseif ipcPARAM == 123 then


        ipc.writeLvar("L:RightBatSwitch", 0)
        ipc.control(66587, 8027)
        ipc.sleep(250)
        ipc.writeLvar("L:LeftBatSwitch", 0)
        ipc.control(66587, 8027)


------------------------------------------------------------ Avionics

-- Left AVIONICS SWITCh TOGGLE
elseif ipcPARAM == 125 then


        LVarSet = "L:LeftAvionicsMaster"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar("L:LeftAvionicsMasterGuard", val)
        ipc.control(66587, 8026)
        ipc.sleep(500)

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8027)




-- RIGHT AVIONICS SWITCh TOGGLE
elseif ipcPARAM == 126 then


        LVarSet = "L:RightAvionicsMaster"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar("L:RightAvionicsMasterGuard", val)
        ipc.control(66587, 8026)
        ipc.sleep(500)

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8027)




-- both AVIONICS SWITCh on
elseif ipcPARAM == 127 then


        ipc.writeLvar("L:RightAvionicsMasterGuard", 1)
        ipc.control(66587, 8026)
        ipc.sleep(400)
        ipc.writeLvar("L:RightAvionicsMaster", 1)
        ipc.control(66587, 8028)
        ipc.sleep(100)


        ipc.writeLvar("L:LeftAvionicsMasterGuard", 1)
        ipc.control(66587, 8026)
        ipc.sleep(400)
        ipc.writeLvar("L:LeftAvionicsMaster", 1)
        ipc.control(66587, 8028)



-- both AVIONICS SWITCh off
elseif ipcPARAM == 128 then


        ipc.writeLvar("L:RightAvionicsMasterGuard", 0)
        ipc.control(66587, 8026)
        ipc.sleep(400)
        ipc.writeLvar("L:RightAvionicsMaster", 0)
        ipc.control(66587, 8027)
        ipc.sleep(100)


        ipc.writeLvar("L:LeftAvionicsMasterGuard", 0)
        ipc.control(66587, 8026)
        ipc.sleep(400)
        ipc.writeLvar("L:LeftAvionicsMaster", 0)
        ipc.control(66587, 8027)


------------------------------------------------------------ GEN

-- LEFT Generator SWITCH TOGGLE
elseif ipcPARAM == 130 then


        LVarSet = "L:LeftGenSwitch"
        val = 1

        if ipc.readLvar(LVarSet) == 1  then
        val = 2
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8027)


-- right Generator SWITCH TOGGLE
elseif ipcPARAM == 131 then


        LVarSet = "L:RightGenSwitch"
        val = 1

        if ipc.readLvar(LVarSet) == 1  then
        val = 2
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8027)


-- left Generator SWITCH on
elseif ipcPARAM == 132 then


        ipc.writeLvar("L:LeftGenSwitch", 2)
        ipc.control(66587, 8027)


-- left Generator SWITCH off
elseif ipcPARAM == 133 then


        ipc.writeLvar("L:LeftGenSwitch", 1)
        ipc.control(66587, 8028)



-- right Generator SWITCH on
elseif ipcPARAM == 134 then


        ipc.writeLvar("L:RightGenSwitch", 2)
        ipc.control(66587, 8027)


-- right Generator SWITCH off
elseif ipcPARAM == 135 then


        ipc.writeLvar("L:RightGenSwitch", 1)
        ipc.control(66587, 8028)


------------------------------------------------------------ FUEL PUMPS


-- Left fuel Pump on
elseif ipcPARAM == 136 then

        ipc.writeLvar("L:LeftStbyFuelPump", 1)
        ipc.control(66587, 8028)


-- Left fuel Pump off
elseif ipcPARAM == 137 then

        ipc.writeLvar("L:LeftStbyFuelPump", 0)
        ipc.control(66587, 8027)


-- right fuel Pump on
elseif ipcPARAM == 138 then

        ipc.writeLvar("L:RightStbyFuelPump", 1)
        ipc.control(66587, 8028)


-- right fuel Pump off
elseif ipcPARAM == 139 then

        ipc.writeLvar("L:RightStbyFuelPump", 0)
        ipc.control(66587, 8027)

------------------------------------------------------------ Prop sync
-- prop sync toggle
elseif ipcPARAM == 140 then   
        LVarSet = "L:PropSync"
        val = 0
        val2 = 8027
        if ipc.readLvar(LVarSet) == 0 then
        val = 1
        val2 = 8028
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, val2)


------------------------------------------------------------ Ground spoiler
--  Ground Spoiler switch on
elseif ipcPARAM == 145 then

                ipc.writeLvar("L:GrndSpoilersSwitch", 1)
                ipc.control(66587,8034)



-- Ground Spoiler switch off
elseif ipcPARAM == 146 then

                ipc.writeLvar("L:GrndSpoilersSwitch", 0)
                ipc.control(66587,8034)


-- Ground Spoiler switch toggle
elseif ipcPARAM == 147 then

        LVarSet = "L:GrndSpoilersSwitch"
        val = 0

        if ipc.readLvar(LVarSet) == 0 then
        val = 1
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8034)

------------------------------------------------------------ Ice oBS lights
-- Ice OBS lights on
elseif ipcPARAM == 148 then
        ipc.writeLvar("IceOBSSwitch", 2)

        ipc.control(66587,8027)


-- Ice OBS lights off
elseif ipcPARAM == 149 then
        ipc.writeLvar("IceOBSSwitch", 0)

        ipc.control(66587,8028)

------------------------------------------------------------ Windshield Deice
-- windshield deice on
elseif ipcPARAM == 150 then
        ipc.writeLvar("LeftWSAntice", 2)
        ipc.writeLvar("RightWSAntice", 1)
        ipc.control(66587,8027)


-- windshield deice off
elseif ipcPARAM == 151 then
        ipc.writeLvar("LeftWSAntice", 1)
        ipc.writeLvar("RightWSAntice", 0)
        ipc.control(66587,8028)

------------------------------------------------------------ Airdata Deice
-- airdata deice on
elseif ipcPARAM == 152 then
        ipc.writeLvar("LeftAirData", 1)
        ipc.writeLvar("RightAirData", 1)
        ipc.control(66587,8027)


-- airdata deice off
elseif ipcPARAM == 153 then
        ipc.writeLvar("LeftAirData", 0)
        ipc.writeLvar("RightAirData", 0)
        ipc.control(66587,8028)



------------------------------------------------------------ Prop Deice
-- Prop deice short on
elseif ipcPARAM == 155 then
        val = 2
        SWvar = ipc.readLvar("LeftPropDeice")
        if SWvar == 0 then
        val = 1 
        end
        ipc.writeLvar("LeftPropDeice", val)
        ipc.writeLvar("RightPropDeice", val)
        ipc.control(66587,8027)


-- Prop deice off
elseif ipcPARAM == 156 then
        ipc.writeLvar("LeftPropDeice", 1)
        ipc.writeLvar("RightPropDeice", 1)
        ipc.control(66587,8028)

-- Prop deice long on
elseif ipcPARAM == 157 then

        val = 0
        SWvar = ipc.readLvar("LeftPropDeice")
        if SWvar == 2 then
        val = 1 
        end
        ipc.writeLvar("LeftPropDeice", val)
        ipc.writeLvar("RightPropDeice", val)
        ipc.control(66587,8027)
------------------------------------------------------------ Deice Auto cycle

-- CCT Auto Cycle Switch
elseif ipcPARAM == 158 then

        ipc.writeLvar("L:AutoAnticeCycle", 2)
        ipc.control(66587, 8028)

        ipc.sleep(400)
        ipc.writeLvar("L:AutoAnticeCycle", 1)
        ipc.control(66587, 8027)


------------------------------------------------------------ warning mute
--warning mute switch toggle
elseif ipcPARAM == 160 then

        LVarSet = "L:CapMuted"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8031)
        ipc.sleep(100)
        ipc.writeLvar("L:CapMuteSwitch", val)

        ipc.control(66587, 8031)

------------------------------------------------------------ TOCW test switch
-- TOCW Testswitch ON
elseif ipcPARAM == 165 then

        ipc.control(66587, 8021)        
        ipc.writeLvar("L:TocwTestSwitch", 1)


-- TOCW Testswitch OFF
elseif ipcPARAM == 166 then

        ipc.control(66587, 8021)        
        ipc.writeLvar("L:TocwTestSwitch", 0)


------------------------------------------------------------ signs
-- Seatbelt on
elseif ipcPARAM == 170 then

        ipc.writeLvar("L:FastenSeatbeltSigns", 1)
        ipc.control(66587, 8028)
        ipc.sleep(10)
        ipc.control(66587, 74)


-- Seatbelt off
elseif ipcPARAM == 171 then

        ipc.writeLvar("L:FastenSeatbeltSigns", 0)
        ipc.control(66587, 8027)
        ipc.sleep(10)
        ipc.control(66587, 74)


-- no smoking on
elseif ipcPARAM == 172 then

        ipc.writeLvar("L:NoSmokingSigns", 1)
        ipc.control(66587, 8028)
        ipc.sleep(10)
        ipc.control(66587, 74)


-- no skmoking off
elseif ipcPARAM == 173 then

        ipc.writeLvar("L:NoSmokingSigns", 0)
        ipc.control(66587, 8027)
        ipc.sleep(10)
        ipc.control(66587, 74)


------------------------------------------------------------ feathering

-- engine 1 (LEFT)
elseif ipcPARAM == 176 then   

        ipc.writeLvar("L:UnFeather", -1)
                ipc.control(66587, 1420)
        ipc.control(66587, 8029) -- knob sound

-- no engine 
elseif ipcPARAM == 177 then   

        ipc.writeLvar("L:UnFeather", 0)
        ipc.control(66587, 8029) -- knob sound

-- engine 2 (RIGHT)
elseif ipcPARAM == 178 then   

        ipc.writeLvar("L:UnFeather", 1)
                ipc.control(66587, 1421)
        ipc.control(66587, 8029) -- knob sound

------------------------------------------------------------ engine starting


-- select engine 1 (LEFT)
elseif ipcPARAM == 180 then   

        if ipc.readLvar("L:StartMasterKnob") == 2  then

                ipc.writeLvar("L:StartMasterKnob", 1)
        ipc.display("no engine selected...")
        ipc.sleep(1000)

        elseif ipc.readLvar("L:StartMasterKnob") == 1  then

                ipc.writeLvar("L:StartMasterKnob", 0)
        ipc.display("left engine selected...")
        ipc.sleep(1000)
        end

-- select engine 2 (RIGHT)
elseif ipcPARAM == 181 then   


        if ipc.readLvar("L:StartMasterKnob") == 0  then

                ipc.writeLvar("L:StartMasterKnob", 1)
        ipc.display("no engine selected...")
        ipc.sleep(1000)

        elseif ipc.readLvar("L:StartMasterKnob") == 1  then

                ipc.writeLvar("L:StartMasterKnob", 2)
        ipc.display("right engine selected...")
        ipc.sleep(1000)
        end


-- unselect engines
elseif ipcPARAM == 182 then   


                ipc.writeLvar("L:StartMasterKnob", 1)
        ipc.display("no engine selected...")
        ipc.sleep(1000)


-- Feathering and starting selected engine -----------------
elseif ipcPARAM == 185 then   



-- Feathering and starting left engine

                if ipc.readLvar("L:StartMasterKnob") == 0  then


                ipc.control(66587, 1420)
        ipc.control(66587, 8029) -- knob sound
        ipc.display("feathering left engine...")

        ipc.sleep(8000) -- waiting for feathering

        ipc.display("feathering left engine...\n Starting left engine")


        ipc.writeLvar("L:LeftStart", 1)

        ipc.writeLvar("L:StartOneToggle", 1)
        ipc.writeLvar("L:LeftStartCheck", 1)
        ipc.writeLvar("L:LeftStartTimer", 1)


        end



-- Feathering and starting right engine


        if ipc.readLvar("L:StartMasterKnob") == 2  then


        ipc.control(66587, 1421)
        ipc.control(66587, 8029) -- knob sound
        ipc.display("feathering right engine...")

        ipc.sleep(8000) -- waiting for feathering

        ipc.display("feathering right engine...\n Starting right engine")


        ipc.writeLvar("L:RightStart", 1)

        ipc.writeLvar("L:StartTwoToggle", 1)
        ipc.writeLvar("L:RightStartCheck", 1)
        ipc.writeLvar("L:RightStartTimer", 1)

        end

ipc.display("")


-- abort starting sequence (stop) for selected engine -----------------
elseif ipcPARAM == 186 then 


-- right engine stop

        if ipc.readLvar("L:StartMasterKnob") == 2  then

        -- Open the stop switch guard
        RSG = ipc.readLvar("L:RightEngStopSwitchGuard")
        if RSG == 0 then
        ipc.writeLvar("L:RightEngStopSwitchGuard", 1)
        ipc.control(66587, 8010)
        end

        -- Press the stop switch
        ipc.sleep(700)
        ipc.writeLvar("L:StopTwoToggle", 1)
        ipc.control(66587, 100001)

        ipc.control(66587, 8042)
        ipc.control(66587, 16)
        ipc.control(66301)

        ipc.control(66587, 100002)

        ipc.sleep(200)
        ipc.writeLvar("L:StopTwoToggle", 0)
        ipc.control(66587, 8042)

        -- Close the stop switch guard
        ipc.sleep(200)
        ipc.writeLvar ("L:RightEngStopSwitchGuard", 0)
        ipc.control (66587, 8010)

        end

-- left engine stop
        if ipc.readLvar("L:StartMasterKnob") == 0  then

 -- Open the stop switch guard
        LSG = ipc.readLvar("L:LeftEngStopSwitchGuard")
        if LSG == 0 then
        ipc.writeLvar("L:LeftEngStopSwitchGuard", 1)
        ipc.control(66587, 8010)
        end

        -- Press the stop switch
        ipc.sleep(700)
        ipc.writeLvar("L:StopOneToggle", 1)
        ipc.control(66587, 100001)

        ipc.control(66587, 8042)
        ipc.control(66587, 15)
        ipc.control(66300)

        ipc.control(66587, 100002)

        ipc.sleep(200)
        ipc.writeLvar("L:StopOneToggle", 0)
        ipc.control(66587, 8042)

        -- Close the stop switch guard
        ipc.sleep(200)
        ipc.writeLvar ("L:LeftEngStopSwitchGuard", 0)
        ipc.control (66587, 8010)

        end
ipc.display("engine starting sequence stopped") 
ipc.sleep(1000)
ipc.display("")

--------------------------------------------------------------

-- starting selected engine -----------------
elseif ipcPARAM == 187 then   



-- starting left engine

                if ipc.readLvar("L:StartMasterKnob") == 0  then


        ipc.writeLvar("L:LeftStart", 1)

        ipc.writeLvar("L:StartOneToggle", 1)
        ipc.writeLvar("L:LeftStartCheck", 1)
        ipc.writeLvar("L:LeftStartTimer", 1)


        end



-- starting right engine


        if ipc.readLvar("L:StartMasterKnob") == 2  then


        ipc.writeLvar("L:RightStart", 1)

        ipc.writeLvar("L:StartTwoToggle", 1)
        ipc.writeLvar("L:RightStartCheck", 1)
        ipc.writeLvar("L:RightStartTimer", 1)

        end





-- toggle gust locks
elseif ipcPARAM == 190 then   

        LVarSet = "L:GustLocks"
        val = 0

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 141)




--Ground power switch toggle 
elseif ipcPARAM == 195 then

        LVarSet = "L:GndPowerSwitch"
        LVar2Set = "L:PowerCartVis"

        val = 0
        val2 = 1

        if ipc.readLvar(LVarSet) == 0  then
        val = 1
        val2 = 0
        end


        ipc.writeLvar(LVar2Set, val2)
        ipc.sleep (300)
        ipc.writeLvar(LVarSet, val)


        ipc.control(66587, 8027)


--------------------------------------------------------------
-- yellow attention get switch
elseif ipcPARAM == 198 then

        ipc.writeLvar("L:LeftAmberAtgetSwitch", 1)
        ipc.control(66587,2090)
        ipc.control(66587,8044)
        ipc.sleep(400)
        ipc.writeLvar("L:LeftAmberAtgetSwitch", 0)
        ipc.control(66587,2091)
        ipc.control(66587,8045)

--------------------------------------------------------------

--  Anti Skid on
elseif ipcPARAM == 200 then

                ipc.writeLvar("L:AntiSkid", 1)
                ipc.control(66587,8029)



--  Anti Skid off
elseif ipcPARAM == 201 then

                ipc.writeLvar("L:AntiSkid", 0)
                ipc.control(66587,8029)


--  Anti Skid  toggle
elseif ipcPARAM == 202 then

        LVarSet = "L:AntiSkid"
        val = 0

        if ipc.readLvar(LVarSet) == 0 then
        val = 1
                end

        ipc.writeLvar(LVarSet, val)
        ipc.control(66587, 8029)



---------------------------------------------------------------------
end





-------------------------------------------------------------------------------
-- you can delete this part below the lines if you don't use a VRInsight device
-------------------------------------------------------------------------------

-------------------------------------
                buffer = ipc.readLvar("L:AltSelAlt")/100
                if buffer <= 0 then
                buffer = 0
                end

                com.write(dev, string.format("ALT%03d", buffer), 8)
-------------------------------------
                buffer = ipc.readLvar("L:HDGBug")
                com.write(dev, string.format("HDG%03d", buffer), 8)

-- ipc.display(ipc.readLvar("L:AltSelAlt"))
-- ipc.sleep(1000)

Link to comment
Share on other sites

  • 4 months later...
  • 3 weeks later...
  • 1 month later...

Thanks Günter for this.

For what it's worth, here's a little mod to add knob acceleration.

This example is for the ALT SEL knob:

require "socket"
KNOB_SENSITIVITY 		= 50
KNOB_ACCELERATION 		= 6

-- ALT plus

elseif ipcPARAM == 10  then
	thisALTinc = socket.gettime()*1000
	lastALTinc = ipc.get("lastALTinc")
	ipc.set("lastALTinc", thisALTinc)

	Var = ipc.readLvar("IrcAltSelKnob")
	if Var >= 100 then 
	Var = 1
	end

	if (thisALTinc - lastALTinc) > KNOB_SENSITIVITY then
		ipc.writeLvar("IrcAltSelKnob", Var+1)

		ipc.control(66587,3921)
		ipc.control(66587,8031)

	else
		ipc.writeLvar("IrcAltSelKnob", Var+3)

		for n=1, KNOB_ACCELERATION, 1 do
			ipc.control(66587,3921)
		end
		ipc.control(66587,8031)
	end

and the release buttons for the condition levers:

-- Right Latch Release ON
elseif ipcPARAM == 1001 then
	ipc.writeLvar("RightLatchRelease", 1);

-- Right Latch Release OFF
elseif ipcPARAM == 1002 then
	ipc.writeLvar("RightLatchRelease", 0);

-- Left Latch Release ON
elseif ipcPARAM == 1003 then
	ipc.writeLvar("LeftLatchRelease", 1);

-- Left Latch Release OFF
elseif ipcPARAM == 1004 then
	ipc.writeLvar("LeftLatchRelease", 0);

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.