Jump to content

Archived

This topic is now archived and is closed to further replies.

guenseli

J41: you want cold and dark? Here you go...

Recommended Posts

Hello,for all registered FSUIP Users I have written a little LUA file that sets the aircraft to cold and dark.Here's what will be happen if you activate the LUA:Engine right will be stoppedEngine left will be stoppedBoth Generator Switches OFFBoth Battery Switches OFFBoth Fuel Pump Switches OFFBoth Avionics OFFThe Power Source dial Knob goes to OFFBoth Yokes go downIt doesn't matter in which state the above switches are: they always go OFF, when this LUA is activated.It doesn't matter if your engines are running or not - they will be shut down!So: DON'T USE THIS DURING FLIGHT!!!!! :( Or use it and look what happens ;-)You can use this LUA by assigning it to a simple button or keycommand.Latest Version of FSUIPC is 4.548 is recomendedYou get it here: FSUIPC 4.548Heres the code:

ipc.sleep(2000)-- RIGHT Engine OFF 	RSG = ipc.readLvar("L:RightEngStopSwitchGuard")	if RSG == 0 then   	ipc.writeLvar("L:RightEngStopSwitchGuard", 1)	ipc.control(66587, 8010)	elseif RSG == 1 then	end		ipc.sleep(700)	ipc.writeLvar("L:StopTwoToggle", 1)	ipc.control(66587, 8042)	ipc.control(66587, 16)	ipc.sleep(200)	ipc.writeLvar("L:StopTwoToggle", 0)	ipc.control(66587, 8042)ipc.sleep(2000)-- LEFT Engine OFF 	LSG = ipc.readLvar("L:LeftEngStopSwitchGuard")	if LSG == 0 then   	ipc.writeLvar("L:LeftEngStopSwitchGuard", 1)	ipc.control(66587, 8010)	elseif LSG == 1 then	end		ipc.sleep(700)	ipc.writeLvar("L:StopOneToggle", 1)	ipc.control(66587, 8042)	ipc.control(66587, 15)	ipc.sleep(200)	ipc.writeLvar("L:StopOneToggle", 0)	ipc.control(66587, 8042)ipc.sleep(1000)-- LEFT Generator SWITCH off	LGen = ipc.readLvar("L:LeftGenSwitch")	if LGen == 2 then   	ipc.writeLvar("L:LeftGenSwitch", 1)	ipc.control(66587, 8027)	elseif LGen == 1 then	endipc.sleep(200)-- RIGHT Generator SWITCH off	RGen = ipc.readLvar("L:RightGenSwitch")	if RGen == 2 then   	ipc.writeLvar("L:RightGenSwitch", 1)	ipc.control(66587, 8027)	elseif RGen == 1 then	endipc.sleep(200)-- LEFT Battery SWITCH off	LBat = ipc.readLvar("L:LeftBatSwitch")	if LBat == 1 then   	ipc.writeLvar("L:LeftBatSwitch", 0)	ipc.control(66587, 8028)	elseif LBat == 0 then	endipc.sleep(200)-- Right Battery SWITCH off	RBat = ipc.readLvar("L:RightBatSwitch")	if RBat == 1 then   	ipc.writeLvar("L:RightBatSwitch", 0)	ipc.control(66587, 8028)	elseif RBat == 0 then	endipc.sleep(200)-- Left AVIONICS SWITCh OFF	LAvM = ipc.readLvar("L:LeftAvionicsMaster")	if LAvM == 1 then   	ipc.writeLvar("L:LeftAvionicsMasterGuard", 0)	ipc.control(66587, 8026)	ipc.sleep(500)   	ipc.writeLvar("L:LeftAvionicsMaster", 0)	ipc.control(66587, 8027)	elseif LAvM == 0 then	endipc.sleep(200)-- RIGHT AVIONICS SWITCh OFF	RAvM = ipc.readLvar("L:RightAvionicsMaster")	if RAvM == 1 then   	ipc.writeLvar("L:RightAvionicsMasterGuard", 0)	ipc.control(66587, 8026)	ipc.sleep(500)   	ipc.writeLvar("L:RightAvionicsMaster", 0)	ipc.control(66587, 8027)	elseif RAvM == 0 then	endipc.sleep(200)-- LEFT Fuel Pump SWITCH off	LFuel = ipc.readLvar("L:LeftStbyFuelPump")	if LFuel == 1 then   	ipc.writeLvar("L:LeftStbyFuelPump", 0)	ipc.control(66587, 8027)	elseif LFuel == 0 then	endipc.sleep(200)-- RIGHT Fuel Pump SWITCH off	RFuel = ipc.readLvar("L:RightStbyFuelPump")	if RFuel == 1 then   	ipc.writeLvar("L:RightStbyFuelPump", 0)	ipc.control(66587, 8027)	elseif RFuel == 0 then	endipc.sleep(200)-- DC PowersourceKnob OFF	DCP = ipc.readLvar("L:DCPowerSourceKnob")	if DCP >= 1 then   	ipc.writeLvar("L:DCPowerSourceKnob", 0)	ipc.control(66587, 8039)	elseif DCP == 0 then	endipc.writeLvar("L:CPYokeUpDown", 1)ipc.writeLvar("L:PICYokeUpDown", 1)

(copy and paste into Editor or WordPad or anything else and save the file into your modules folder named:J41_CD.LUAYou can assign this via FSUIPC menu under the command Lua J41_CDHave fun!oh, for the formalities: my name is Guenter Steiner :(


Guenter Steiner
--------------------------------------------------------------------------------------
LINDA Lua Integrated Non-complex Device Assigning

Betatester for: A2A, Hifi, Simstarter, AivlaSoft 
--------------------------------------------------------------------------------------

Share this post


Link to post
Guest manx

very nice, works great, thankyou!would you happen to know the LVAR for the beacon, nav and strobe lights?John

Share this post


Link to post

Hello Guenter,works very well. I always look at posts from You, so I have learned many things to programm my Hardwarepanel for the J41. With LUA and Macros it makes much fun and all key assignments work great.Therefor many thanks to You.Kind RegardsRalf H

Share this post


Link to post

HiThe Lua cold and dark file works like a charm, once again thank you for the work you are doing on these files.Jim Hodkinson

Share this post


Link to post

Thanks for sharing, Guenter!Some additonal lua code to turn off beacon, windshield anti-ice and air data anti-ice:

-- Beacon offBCN = logic.And(ipc.readUW(0x0D0C), 0x2)if BCN ~= 0 thenipc.control(66239)ipc.control(66587,8027)endipc.sleep(200)-- Left Windshield Antiice offLWS = ipc.readLvar("L:LeftWSAntice")if (LWS == 2 or LWS == 0) thenipc.writeLvar("L:LeftWSAntice",1)ipc.control(66587,8027)endipc.sleep(200)-- Right Windshield Antiice offRWS = ipc.readLvar("L:RightWSAntice")if RWS == 1 thenipc.writeLvar("L:RightWSAntice",0)ipc.control(66587,8027)endipc.sleep(200)-- Left Air Data offLAD = ipc.readLvar("L:LeftAirData")if LAD == 1 thenipc.writeLvar("L:LeftAirData",0)ipc.control(66587,8027)endipc.sleep(200)-- Right Air Data offRAD = ipc.readLvar("L:RightAirData")if RAD == 1 thenipc.writeLvar("L:RightAirData",0)ipc.control(66587,8027)end

Share this post


Link to post

Guenter,Thanks for your neat program!Yet, I tried to use it but without sucess! I thave the LUA file containing your code in the modules folder. But I cannot see anything in the FSIUPC menu that links to this LUA file!Can you please give some more details so I can give a keystroke to perform this cold and dark J41 procedure? I do use the latest FSIUPC as you recommended and in the FSIUPC ini file I do have[LuaFiles]1=J41_CDThanksEdmundo


Edmundo Azevedo

Share this post


Link to post
Yet, I tried to use it but without sucess! I thave the LUA file containing your code in the modules folder. But I cannot see anything in the FSIUPC menu that links to this LUA file!
In FSX, open the FSUIPC interface. Go to the "buttons+switches" tab, press the joystick button you want to map. Check "Select for FS control", go to the "control sent when button pressed" scroll-list and select "Lua J41_CD" (last step assuming you saved the code as J41_CD.LUA in the modules folder).

Share this post


Link to post

Thanks Tom! Yet when I select the "buttons+switches" tab in FSIUPC, the Press Jostick or (Buttons) boxes are greyed (i.e. non-selectable). It is rnecessary to include any additional information in any place, such as in the Simconnect file?It seems I need to read the manuals that come with FSIUPC!BestEdmundo

In FSX, open the FSUIPC interface. Go to the "buttons+switches" tab, press the joystick button you want to map. Check "Select for FS control", go to the "control sent when button pressed" scroll-list and select "Lua J41_CD" (last step assuming you saved the code as J41_CD.LUA in the modules folder).

Edmundo Azevedo

Share this post


Link to post

@Tomthanks very much, I'll have to play around with the logic.AND thingie a little bit.interesting...@edmundodo you have registered version of FSUIPC?Can you assign any commands else?


Guenter Steiner
--------------------------------------------------------------------------------------
LINDA Lua Integrated Non-complex Device Assigning

Betatester for: A2A, Hifi, Simstarter, AivlaSoft 
--------------------------------------------------------------------------------------

Share this post


Link to post

Hi,I do you have a registered version of FSUIPC. I use the latest version (issued on November 6).I am not sure if I can assign any commands. Will check.I did put another LUA file in the Modules folder (that came with FSIUPV download), and though it also registers in FSIUPC ini file, I still have the greyed boxes for joystick and keyboard command selection.ThanksEdmundo

@Tomthanks very much, I'll have to play around with the logic.AND thingie a little bit.interesting...@edmundodo you have registered version of FSUIPC?Can you assign any commands else?

Edmundo Azevedo

Share this post


Link to post
I still have the greyed boxes for joystick and keyboard command selection.
It seems you have a general problem with FSUIPC.Can you make a screenshot of the FSUIPC menue?Maybe you should go to the FSUIPC Forum for further questions?

Guenter Steiner
--------------------------------------------------------------------------------------
LINDA Lua Integrated Non-complex Device Assigning

Betatester for: A2A, Hifi, Simstarter, AivlaSoft 
--------------------------------------------------------------------------------------

Share this post


Link to post
Yet when I select the "buttons+switches" tab in FSIUPC, the Press Jostick or (Buttons) boxes are greyed (i.e. non-selectable). It is rnecessary to include any additional information in any place, such as in the Simconnect file?
Did you try pressing a joystick button with this screen opened? This is what it looks like before you press a button (screengrab from the manual):When you press a joystick button, it should appear where it says "PRESS BUTTON". You can now make the selections I described aboveTom

Share this post


Link to post

Got it working! Very, very useful. Thanks Tom and Guenter for your help!Kind regardsEdmundo


Edmundo Azevedo

Share this post


Link to post

Guenter Thanks for your posts including this one and the macros and the "Lua" file. They have really enhanced my flying the J41 and I now control many functions with my GoFlight switch panels. Excellent.I just noticed for the first time that on this Cold and Dark Lua file the switchguards for the engine stop switches remain open. I've added a bit of code (adapting from your file) to close them at the end of the sequence. Its here if anyone wants it:--RIGHT STOP SWITCHGUARD OFFRSG = ipc.readLvar("L:RightEngStopSwitchGuard")if RSG == 1 thenipc.writeLvar("L:RightEngStopSwitchGuard", 0)ipc.control(66587, 8010)elseif RSG == 0 thenendipc.sleep(700)--LEFT STOP SWITCHGUARD OFFLSG = ipc.readLvar("L:LeftEngStopSwitchGuard")if LSG == 1 thenipc.writeLvar("L:LeftEngStopSwitchGuard", 0)ipc.control(66587, 8010)elseif LSG == 0 thenendipc.sleep(700)endI'm working on another Lua file for more commands, again learning from your and Tom's (Thanks Tom) stuff here. I'm no programmer but I've figured out most of it except the lines like "ipc.control(66587, 8010)". Could you explain to me what this does, how do you know what the numbers should be and where do you get them from.Thanks again for your great contribution to flying the J41 using Hardware.Richard Cooke

Share this post


Link to post
×
×
  • Create New...