Sign in to follow this  
guenseli

reworked PMDG J41 LUA Script

Recommended Posts

Hello,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 Word Not Allowed!!!(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 forum and manuals!Please read and you will understand!!!Have fun!!!GünterHere 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 toggleNow, the LUA code will follow (because I could not attach a file here, sorry)

-- 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 Word Not Allowed 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"endspeed = 115200 handshake = 0  minsize = 8maxsize = 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 selif 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 pluselseif 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)	   	ipc.sleep(40)-- ALT plus fastelseif 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)	   	ipc.sleep(40)-- ALT minuselseif 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)	   	ipc.sleep(40)-- ALT minus fastelseif 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)	   	ipc.sleep(40)-- ALT holdelseif 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 pluselseif ipcPARAM == 15 then	   	ipc.control(66587,26902)				ipc.control(66587,8031)	   	ipc.sleep(50)-- HDG plus fastelseif ipcPARAM == 16 then		for n=1, 10, 1 do	   	ipc.control(66587,26902)		end		ipc.control(66587,8031)	   	ipc.sleep(50)-- HDG minuselseif ipcPARAM == 17 then	   	ipc.control(66587,26901)				ipc.control(66587,8031)	   	ipc.sleep(50)-- HDG minus fastelseif ipcPARAM == 18 then		for n=1, 10, 1 do	   	ipc.control(66587,26901)		end		ipc.control(66587,8031)	   	ipc.sleep(50)-- 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 presselseif 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 incelseif 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)	   	ipc.sleep(40)		buffer = ipc.readLvar("L:VSIASTarget")		com.write(dev, string.format("DSP_%04d", buffer), 8)-- VS decelseif 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)	   	ipc.sleep(40)		buffer = ipc.readLvar("L:VSIASTarget")		com.write(dev, string.format("DSP_%04d", buffer), 8)-- CRS presselseif 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 presselseif 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 fastelseif ipcPARAM == 37 then		for n=1, 10, 1 do	   	ipc.control(66587,26802)		end		ipc.control(66587,8031)	   	-- IAS minuselseif ipcPARAM == 38 then	   	ipc.control(66587,26801)		ipc.control(66587,8031)-- IAS minus fastelseif 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)-- APRelseif 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)-- VSelseif 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)-- BCelseif 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)-- IASelseif 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)-- STBYelseif 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 onelseif ipcPARAM == 56 then		ipc.writeLvar("L:ApTrimPowerSwitch", 1)		ipc.control(66587,8034)-- AP Trim Power Switch offelseif ipcPARAM == 57 then		ipc.writeLvar("L:ApTrimPowerSwitch", 0)		ipc.control(66587,8034)-- AP Masterelseif 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 offelseif 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 Minuselseif 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 Pluselseif 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 Minuselseif 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 Pluselseif 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)-- ETelseif 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 Toggleelseif 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 Toggleelseif 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 VOR1elseif ipcPARAM == 93 then   	ipc.writeLvar("L:LeftAdfVorSwitch", 1)	ipc.control(66587, 8024)-- Pilot ADF2elseif ipcPARAM == 94 then   	ipc.writeLvar("L:LeftVorAdfSwitch", 1)	ipc.control(66587, 8024)-- Pilot VOR2elseif ipcPARAM == 95 then   	ipc.writeLvar("L:LeftVorAdfSwitch", 0)	ipc.control(66587, 8024)------------------------------------------------------------ Lights-- Panel flood light onelseif ipcPARAM == 100 then   	ipc.writeLvar("L:PanelFloodSW", 1)	ipc.control(66587, 8029)-- Panel flood light offelseif ipcPARAM == 101 then   	ipc.writeLvar("L:PanelFloodSW", 0)	ipc.control(66587, 8029)-- Panel flood light toggleelseif 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 ONelseif 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 OFFelseif 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 toggleelseif 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 toggleelseif ipcPARAM == 106 then 	ipc.control(66376) 	ipc.control(66587,8027)-- BCN light toggleelseif ipcPARAM == 107 then 	ipc.control(66239) 	ipc.control(66587,8027)-- NAV Lights ONelseif ipcPARAM == 108 then		ipc.writeLvar("L:NavLightSwitch", 2)	ipc.control(66587, 8028)-- NAV Lights Offelseif ipcPARAM == 109 then		ipc.writeLvar("L:NavLightSwitch", 1)	ipc.control(66587, 8027)-- NAV light toggleelseif 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 toggleelseif ipcPARAM == 111 then 	ipc.control(65560) 	ipc.control(66587,8028)-- Landing lights toggleelseif ipcPARAM == 112 then 	ipc.control(65751) 	ipc.control(66587,8027)-- Taxi light toggleelseif ipcPARAM == 113 then 	ipc.control(66240) 	ipc.control(66587,8028)-- Consp Lights ONelseif ipcPARAM == 114 then		ipc.writeLvar("L:ConspicLight", 1)	ipc.control(66587, 8028)	ipc.control(66377)-- Consp Lights Offelseif ipcPARAM == 115 then		ipc.writeLvar("L:ConspicLight", 0)	ipc.control(66587, 8027)	ipc.control(66377)-- Consp light toggleelseif 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 TOGGLEelseif 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 TOGGLEelseif 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 onelseif 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 offelseif 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 TOGGLEelseif 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 TOGGLEelseif 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 onelseif 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 offelseif 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 TOGGLEelseif 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 TOGGLEelseif 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 onelseif ipcPARAM == 132 then	ipc.writeLvar("L:LeftGenSwitch", 2)	ipc.control(66587, 8027)-- left Generator SWITCH offelseif ipcPARAM == 133 then	ipc.writeLvar("L:LeftGenSwitch", 1)	ipc.control(66587, 8028)-- right Generator SWITCH onelseif ipcPARAM == 134 then	ipc.writeLvar("L:RightGenSwitch", 2)	ipc.control(66587, 8027)-- right Generator SWITCH offelseif ipcPARAM == 135 then	ipc.writeLvar("L:RightGenSwitch", 1)	ipc.control(66587, 8028)------------------------------------------------------------ FUEL PUMPS-- Left fuel Pump onelseif ipcPARAM == 136 then   	ipc.writeLvar("L:LeftStbyFuelPump", 1)	ipc.control(66587, 8028)-- Left fuel Pump offelseif ipcPARAM == 137 then   	ipc.writeLvar("L:LeftStbyFuelPump", 0)	ipc.control(66587, 8027)-- right fuel Pump onelseif ipcPARAM == 138 then   	ipc.writeLvar("L:RightStbyFuelPump", 1)	ipc.control(66587, 8028)-- right fuel Pump offelseif ipcPARAM == 139 then   	ipc.writeLvar("L:RightStbyFuelPump", 0)	ipc.control(66587, 8027)------------------------------------------------------------ Prop sync-- prop sync toggleelseif 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 onelseif ipcPARAM == 145 then		ipc.writeLvar("L:GrndSpoilersSwitch", 1)		ipc.control(66587,8034)-- Ground Spoiler switch offelseif ipcPARAM == 146 then		ipc.writeLvar("L:GrndSpoilersSwitch", 0)		ipc.control(66587,8034)-- Ground Spoiler switch toggleelseif 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 onelseif ipcPARAM == 148 then	ipc.writeLvar("IceOBSSwitch", 2)	ipc.control(66587,8027)-- Ice OBS lights offelseif ipcPARAM == 149 then	ipc.writeLvar("IceOBSSwitch", 0)	ipc.control(66587,8028)------------------------------------------------------------ Windshield Deice-- windshield deice onelseif ipcPARAM == 150 then	ipc.writeLvar("LeftWSAntice", 2)	ipc.writeLvar("RightWSAntice", 1)	ipc.control(66587,8027)-- windshield deice offelseif ipcPARAM == 151 then	ipc.writeLvar("LeftWSAntice", 1)	ipc.writeLvar("RightWSAntice", 0)	ipc.control(66587,8028)------------------------------------------------------------ Airdata Deice-- airdata deice onelseif ipcPARAM == 152 then	ipc.writeLvar("LeftAirData", 1)	ipc.writeLvar("RightAirData", 1)	ipc.control(66587,8027)-- airdata deice offelseif ipcPARAM == 153 then	ipc.writeLvar("LeftAirData", 0)	ipc.writeLvar("RightAirData", 0)	ipc.control(66587,8028)------------------------------------------------------------ Prop Deice-- Prop deice short onelseif 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 offelseif ipcPARAM == 156 then	ipc.writeLvar("LeftPropDeice", 1)	ipc.writeLvar("RightPropDeice", 1)	ipc.control(66587,8028)-- Prop deice long onelseif 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 Switchelseif 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 toggleelseif 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 ONelseif ipcPARAM == 165 then	ipc.control(66587, 8021)		ipc.writeLvar("L:TocwTestSwitch", 1)-- TOCW Testswitch OFFelseif ipcPARAM == 166 then	ipc.control(66587, 8021)		ipc.writeLvar("L:TocwTestSwitch", 0)------------------------------------------------------------ signs-- Seatbelt onelseif ipcPARAM == 170 then	ipc.writeLvar("L:FastenSeatbeltSigns", 1)    	ipc.control(66587, 8028)	ipc.sleep(10)    	ipc.control(66587, 74)-- Seatbelt offelseif ipcPARAM == 171 then	ipc.writeLvar("L:FastenSeatbeltSigns", 0)    	ipc.control(66587, 8027)	ipc.sleep(10)    	ipc.control(66587, 74)-- no smoking onelseif ipcPARAM == 172 then	ipc.writeLvar("L:NoSmokingSigns", 1)    	ipc.control(66587, 8028)	ipc.sleep(10)    	ipc.control(66587, 74)-- no skmoking offelseif 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 engineselseif 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)	endipc.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)	endipc.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 lockselseif 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 switchelseif 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 onelseif ipcPARAM == 200 then		ipc.writeLvar("L:AntiSkid", 1)		ipc.control(66587,8029)--  Anti Skid offelseif ipcPARAM == 201 then		ipc.writeLvar("L:AntiSkid", 0)		ipc.control(66587,8029)--  Anti Skid  toggleelseif 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)

Share this post


Link to post
Help AVSIM continue to serve you!
Please donate today!

Thanks again for sharing your wonderful work with others!

Share this post


Link to post

I just love these LUA files. Thanks so much for the time and effort you put into these files but above all for willingness to share the info.

Share this post


Link to post

Using the above lua script, I assigned the Jetstream's SPD knob to my VRinsight M Panel, but for some reason I can't explain FS freezes as soon as I turn the knob a couple of times. Can anyone help me on this?

Share this post


Link to post

I'm trying to use this script but with no luck. :(I assigned a button to Lua script with parameter 58 (AP Master) and when I'm pressing this button AP lights on and right then Crash To Desktop is happening.What I'm doing wrong?Any help will be greatly appreciated Best regardsPiotr Dabrowski

Share this post


Link to post

Kevin/Piotr,The first post mentions an FSUIPC VRInsight Mod. Do you have this?Otherwise, I have no clue.

Share this post


Link to post

I don't have, but in the script there are lines to remove in the case not having VRInsight. And so I did.

Share this post


Link to post

Thanks for the link, but I found out that I already have that. I just didn't know it was called a 'mod'. The weird thing is that according to the first post, I should have synchronised displays, but I don't. Does this maybe only apply to the VRinsight MCP? I only have the VRinsight M Panel.

Share this post


Link to post

Hi,I stated at the initial post: "Maybe ist working for other VRInsight devices too, but I don't know - try it!"I really don't know it. I'm no expert on this whole stuff - I just know how to collect LUA variables.But: if you you have "just" a MPanel, theres nothing to synchronise with any display.The Mpanel has just NAV displays and they should work naturally.In my LUA script, theres no sync for the NAV and COM section, just for HDG, ALT an VertSpeedAnd yes, nobody just me call that "VRInsight FSUIPC mod".But theres also no other name.... so why don't call it "mod" Batting%20Eyelashes.gifI'm sorry that I can't help much with this stuff.As I said I'm no expert on this, just a collector...But FSUIPC manuals do provide much information about that things...

Share this post


Link to post

Thanks for your reply! You shouldn't be sorry, I'm already grateful you made this LUA file! That must've been a hell of a job.Just to make things clear: the VRinsights M Panel's NAV and COM displays are actually working right, but it also does have HDG, VS, ALT, BARO and SPD displays, but I actually don't care if they work or not, because they only really work on the Level-D 767 and default aircraft. What I do care about, is the ability to dial speeds, altitudes and headings into my JS41 using the M Panel, which causes FSX to freeze when I turn to fast.I will try to take a deep look into the FSUIPC manuals to see if I can find something useful. Indeed, they're pretty good manuals!

Share this post


Link to post

thanks for your nice words!Indeed I encountered a similar problem (crashing FSX) the last days.I run twice into a crash when being Online on IVAO. Never had this offline before. But I tried then an excessive dialing offline and forced it also to crash in the end.The thing is, that I have now a pretty fast PC (4.2. Ghz) and maybe it could handle that long LUA very well, but slower PCs maybe run into problems.First question here:Do you have the latest FSUIPC installed? Its currently 4.661.You have to look into his "Download --> Updated modules" threadPete is updating FSUIPC quite often, so you should at least have a look every 14 days there.One solution could be now (haven't tested it, but should help a bit):I have removed the pauses in the code for the dialing sections (ipc.sleep(xx))You can see at the end of this thread the code section without the sleep commands.Just replace that from -------------AP at the beginning to "-- CRS press" (Parameter 30)Second possible solution: you delete this lines from the original script and make a second LUA script just for the code below.Name it e.g. J41dial.LUA. You will find and assign it then in the FSUIPC menu under LUA J41dialLittle background for what I have written above:Every LUA will be opened, read and closed with every time you press a button.If theres too less time for this action and there comes request after request, the script gets stucked, leads to hang.Now if you have a rotary knob and a very long script, this will lead to trouble.Theres a bit of "security" built in FSUIPC to avoid that, thats why you have to get the latest version of FSUIPC (at least 4.6)I try to get a solution by creating scripts in an other "style", but that actually way over my head and I need time to do that...Just have to learn how to do that.If you are interested and would like to help me, please read this thread in the FSUIPC forum:Crash with LUA and rotary switch

-----------------------------------------------------------AP ALT-- ALT selif 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 pluselseif 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 fastelseif 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 minuselseif 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 fastelseif 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 holdelseif 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 pluselseif ipcPARAM == 15 then                ipc.control(66587,26902)                                ipc.control(66587,8031)               -- HDG plus fastelseif ipcPARAM == 16 then                for n=1, 10, 1 do                ipc.control(66587,26902)                end                ipc.control(66587,8031)               -- HDG minuselseif ipcPARAM == 17 then                ipc.control(66587,26901)                                ipc.control(66587,8031)               -- HDG minus fastelseif 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 presselseif 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 incelseif 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 decelseif 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)

Share this post


Link to post

I tried your shortened LUA file, but for some reason that didn't work at all, wich could of course be caused by a mistake I made myself. However, I always thought I had the latest FSUIPC (4.6), but since you posted the link to the updates thread, I realised that there's an even higher version available, so I updated to 4.661. I reverted back to your original (long) LUA file and now, using my M Panel to control the SPD bug, I couldn't get a freeze-up or CTD with the wonderful Jetstream 4100. Thanks for your efforts! It's very much appreciated!Big%20Grin.gif

Share this post


Link to post

Confirmed. Switching logging off in the FSUIPC settings and/or .ini file makes this script work without freezes.Günter, and what about the new version of this script you are working on? Any success?

Share this post


Link to post
Confirmed. Switching logging off in the FSUIPC settings and/or .ini file makes this script work without freezes.Günter, and what about the new version of this script you are working on? Any success?
Yes, I have had "success" with the event.param, meaning it was working in a little test file.But I think the more successful way is to split the LUA scripts into two parts: the "normal" and this one with the AP dial switches to get not too long scripts.So, answering your question: no, theres no new LUA script for the J41

Share this post


Link to post
Yes, I have had "success" with the event.param, meaning it was working in a little test file.But I think the more successful way is to split the LUA scripts into two parts: the "normal" and this one with the AP dial switches to get not too long scripts.So, answering your question: no, theres no new LUA script for the J41
Is there some great difficulties happen with new script model (event.param)?The idea not to reload whole script for each button press (rotary especial) looks quite reasonable. I'm doing some programming myself so it's a technical ineterest. Any unsolvable problems with it?

Share this post


Link to post

I had great difficulties at the beginning, but a nice forum member helped me a lot!event.param is good but isn't as practicable as my "normal" LUAs.As an example:normal LUA is

if param == 10 then ...

for a rotary switch (VRInsight MCP)and with event.param I need to write

if param == 10 or param == 11 then

because the LUA isn't reloading the script.Normally no problem at all, but for me that means that I have to re-do thousands of assignments with my current settings :Whistle:And a second AP scripts solves the problem also (it seems so), so I don't want to do that hard work.

Share this post


Link to post
I had great difficulties at the beginning, but a nice forum member helped me a lot!...
I see. I've just made some tests and have found that event.param algorythm works little better with displaying correct value to VRI MCP. There is little or no lag at displaying value. And as for 100 feet difference, I believe the solution is to set ipc.sleep(40) before code block which writes value back to MCP. Worked in my new script and should work in the old (your's) one.Ex.:
    	    	ipc.sleep(40) -- <<<< HERE IT IS			buffer = ipc.readLvar("L:AltSelAlt")/100		if buffer <= 0 then		buffer = 0		end			com.write(dev, string.format("ALT%03d", buffer), 8)

It seems that this little delay allows to read the correct current value from L:AltSelAlt and the previous one.And moving the COM-port connection procedure to plugin script where it runs only once at script load is a better way to do the thing (than doing the reconnect at each button press). For programmer's point of view. The other part of the script for working with buttons is better to leave as it is (you are right!).I could show the whole script if you're interested in.

Share this post


Link to post
Hi! im looking for a trainer to learn me how to fly this J41!PLEASE REPLY
And you think in a Thread about LUA script you will get the answer??? :(@ Artem,yes I'm very interested in such a good programmed script!!!As you will obvisiously see, I'm no programmer, just fiddling around to get some things to work.I'm very interested in a well programmed LUA script for the J41! (and many others, too)btw: do you know about a way to get the MCP Displays also work in the MD11???many thanks!Günter

Share this post


Link to post

As for MD11 - why not to make it exactly like JS41? If you could get data from MD11 AP then you can write it back to MCP.I don't own the MD11, so can't help with it.And here it what I made based on your script. Nothing special, just reworked and optimized.

--###########################################################----## VRI MCP Rotaries/Display script  v0.9b  11 apr. 2011  ##----## by Artem Crum, artem.crum@gmail.com           		##-- --## Based on script originaly written by Guenter Steiner  ##----###########################################################---- WHAT FOR-- This script is for controlling PMDG JS41 autopilot rotaries with VRInsight MCP Combo unit-- !!! ONLY rotaries rotation is encoded, not the rotary presses or other buttons !!!-- Script updates MCP display info accordingly to what is set inside the simulator-- HOW TO USE-- bla-bla-bla about setting up the staff... -- to be written by someone whou knows english better than I do ---- 1) BTW Script should be started automaticaly form *ipcReady.lua* file in modules folder--	You should ads there smth like that: ipc.runlua("pmdg-js41-rotaries.lua")---- 2) In FSUIPC's Buttons/Switches section the "LuaValue pmdg-js41-rotaries" control should be used-- -- 3) !!! Both press and release settings should be set in FSUIPC for each MCP button !!!-- LuaValue parameters-- Press/Release settings in FSUIPC-------------------------------------- 1/2 - ALT plus-- 3/4 - ALT plus fast-- 5/6 - ALT minus-- 7/8 - ALT minus fast--------------------------------------- 11/12 - HDG plus-- 13/14 - HDG plus fast-- 15/16 - HDG minus-- 17/18 - HDG minus fast--------------------------------------- 21/22 - CRS plus-- 23/24 - CRS plus fast-- 25/26 - CRS minus-- 27/28 - CRS minus fast--------------------------------------- 31/32 - IAS plus-- 33/34 - IAS plus fast-- 35/36 - IAS minus-- 37/38 - IAS minus fast--------------------------------------- 41/42 - VS plus-- 43/44 - VS minus--------------------------------------- Tuning fast rotation speedsfast_alt = 10 -- << increment value when rotary in fast mode fast_hdg = 5fast_crs = 5fast_ias = 3-- VRI settingsif VRImodel == nil then  VRIdevice = "COM3"   VRIdriver = "COM9"endspeed = 115200 handshake = 0  minsize = 8maxsize = 8 	-- ####################################################### ---- ## No more settings below this boundry !!!   		## --	-- ####################################################### ---- Trying to make a persistent connection to VRI MCPdev = 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(5000)end-- Working with MCP Rotariesfunction JS41dials(param)	-- AP ALT Rotary	if param > 0 and param < 10 then			-- ALT plus		if param == 1 or param == 2 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 param == 3 or param == 4 then			Var = ipc.readLvar("IrcAltSelKnob")			if Var > 100 then Var = 1 end			ipc.writeLvar("IrcAltSelKnob", Var+5)			for n=1, fast_alt, 1 do ipc.control(66587,3921) end			ipc.control(66587,8031)		-- ALT minus		elseif param == 5 or param == 6 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 param == 7 or param == 8 then			Var = ipc.readLvar("IrcAltSelKnob")			if Var < 1 then Var = 100 end			ipc.writeLvar("IrcAltSelKnob", Var-5)			for n=1, fast_alt, 1 do ipc.control(66587,3920) end			ipc.control(66587,8031)		end			-- Updating MCP display		-- Only altitude		ipc.sleep(50) -- << waiting for FSX data update				buffer = ipc.readLvar("L:AltSelAlt")/100		if buffer < 0 then buffer = 0 end				com.write(dev, string.format("ALT%03d", buffer), 8)					return -- << finishing function execution	end		-- ############################################################## --			-- AP HDG Rotary	if param > 10 and param < 20 then			-- HDG plus		if param == 11 or param == 12 then			ipc.control(66587,26902)			ipc.control(66587,8031)		-- HDG plus fast		elseif param == 13 or param == 14 then			for n=1, fast_hdg, 1 do ipc.control(66587,26902) end			ipc.control(66587,8031)		-- HDG minus		elseif param == 15 or param == 16 then			ipc.control(66587,26901)			ipc.control(66587,8031)		-- HDG minus fast		elseif param == 17 or param == 18 then			for n=1, fast_hdg, 1 do ipc.control(66587,26901)end			ipc.control(66587,8031)					end					-- Updating MCP display		-- Only heading		ipc.sleep(100) -- << waiting for FSX data update					buffer = ipc.readLvar("L:HDGBug")		com.write(dev, string.format("HDG%03d", buffer), 8)					return -- << finishing function execution	end	-- ############################################################## --	-- AP CRS Rotary	if param > 20 and param < 30 then			-- CRS plus		if param == 21 or param == 22 then			ipc.control(66587,26702)			ipc.control(66587,8031)		-- CRS plus fast		elseif param == 23 or param == 24 then			for n=1, fast_crs, 1 do ipc.control(66587,26702) end			ipc.control(66587,8031)		-- CRS minus		elseif param == 25 or param == 26 then			ipc.control(66587,26701)			ipc.control(66587,8031)		-- CRS minus fast		elseif param == 27 or param == 28 then			for n=1, fast_crs, 1 do ipc.control(66587,26701) end			ipc.control(66587,8031)					end				-- No need to send data to MCP here, just exiting		return -- << finishing function execution	end	-- ############################################################## --		-- AP IAS Rotary	if param > 30 and param < 40 then			-- IAS plus 		if param == 31 or param == 32 then					ipc.control(66587,26802)			ipc.control(66587,8031)		-- IAS plus fast		elseif param == 33 or param == 34 then			for n=1, fast_ias, 1 do ipc.control(66587,26802) end			ipc.control(66587,8031)							-- IAS minus		elseif param == 35 or param == 36 then					ipc.control(66587,26801)			ipc.control(66587,8031)		-- IAS minus fast		elseif param == 37 or param == 38 then			for n=1, fast_ias, 1 do ipc.control(66587,26801) end			ipc.control(66587,8031)				end				-- No need to send data to MCP here, just exiting		return -- << finishing function execution	end	-- ############################################################## --			-- AP VS Rotary	if param > 40 and param < 50 then			-- VS inc		if param == 41 or param == 42 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)						ipc.sleep(40)			buffer = ipc.readLvar("L:VSIASTarget")			com.write(dev, string.format("DSP_%04d", buffer), 8)		-- VS dec		elseif param == 43 or param == 44 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)			ipc.sleep(40)			buffer = ipc.readLvar("L:VSIASTarget")			com.write(dev, string.format("DSP_%04d", buffer), 8)				end				return -- << finishing function execution	end	-- ############################################################## --				endevent.param("JS41dials")

Share this post


Link to post

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
Sign in to follow this