Verybumpy Posted October 29, 2021 Report Posted October 29, 2021 Hi, I can take the easy route and use a non-standard key combination to command door specific Lua's to open exits but prefer not to. Being a newbie, I can't quite figure out a way to make Ctrl+E+1 or 2 or 3 work for corresponding forward, aft and cargo doors. Obviously, like a dozen other key normal commands, the default Ctrl+E+1 FSX input does not work in this plane. Any solution suggestions are appreciated. This is with the far from perfect PMDG DC-6 in FSX btw. -- forward door toggling Lua code-- function DC6_ExitFwd_open () ipc.writeLvar("dc6_446_obj", 1) return end function DC6_ExitFwd_close () ipc.writeLvar("dc6_446_obj", 0) return end function DC6_ExitFwd_toggle () if ipc.readLvar("dc6_446_obj") == 0 then DC6_ExitFwd_open () else DC6_ExitFwd_close () end end DC6_ExitFwd_toggle () return
John Dowson Posted October 29, 2021 Report Posted October 29, 2021 You could run a script on Ctrl+E and then in the script use the event.key function to wait for a keypress (1,2, or 3, so 3 event.key functions) and then, in the keypress function, call the functions to open/close/toggle the appropriate door, based on the key pressed, and then exit. You my also want to add a timer so that if no keypress is received within a certain amount of time, the script also exits. Alternatively, if the time taken to compile and run the lua script on the Ctrl+E keypress takes solong that the 1,2,3 keypress is missed (i.e. pressed before the event.key calls are registered), you could start a script in your DC6 [Auto] section that waits for the CTR+E keypress, and when received add the even.key calls to the 1,2,3 keys, and in the function that handles the 1,2,3 keys you can toggle the appropriate door and then use event.cancel to remove the 1,2,3 key press event. John
Verybumpy Posted October 30, 2021 Author Report Posted October 30, 2021 (edited) I press Shift+E to 'open' this lua and then 1 or 2 but it does not function. Can someone point out to me why this doesn't work? Edit: Getting this error: 120781 KEYDOWN: VK=69, Waiting=0, Repeat=N, Shifts=1 120828 .. This key is programmed in FSUIPC4 'Keys' options 120828 LUA.2: beginning "K:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\DC6exitPickTgle.lua" 120828 *** LUA Error: ...Microsoft Games\Microsoft Flight Simulator X\Modules\DC6exitPickTgle.lua:46: unexpected symbol near 'â' Edit2: ^^^^Figured out the above error. Its was because of the odd font characters carried over from a copy/paste of the pdf within the function of the event.key lines. Edit3: So "DC6_Fwd_Toggle" was left in the code causing only fwd exit to work. Removed that line and now everything works. Just need to put some sort of exit Lua command after each door toggle and hopefully voila. --Calling this Lua with Shift+E in Key Presses --fwd below function DC6_ExitFwd_open () ipc.writeLvar("dc6_446_obj", 1) ipc.display("Front Door OPEN") ipc.sleep(4000) end function DC6_ExitFwd_close () ipc.writeLvar("dc6_446_obj", 0) ipc.display("Front Door CLOSED") ipc.sleep(4000) end function DC6_ExitFwd_toggle () if ipc.readLvar("dc6_446_obj") == 0 then DC6_ExitFwd_open () else DC6_ExitFwd_close () end end DC6_ExitFwd_toggle () --aft below function DC6_ExitAft_open () ipc.writeLvar("dc6_451_obj", 1) ipc.display("Rear Door OPEN") end function DC6_ExitAft_close () ipc.writeLvar("dc6_451_obj", 0) ipc.display("Rear Door CLOSED") end function DC6_ExitAft_toggle () if ipc.readLvar("dc6_451_obj") == 0 then DC6_ExitAft_open () else DC6_ExitAft_close () end end --cargo below soon event.key(49, 8, “DC6_ExitFwd_toggle”) event.key(50, 8, “DC6_ExitAft_toggle”) --event.key(51, 8, “DC6_ExitCargo_toggle”) Edited October 30, 2021 by Verybumpy add log info
John Dowson Posted October 30, 2021 Report Posted October 30, 2021 10 hours ago, Verybumpy said: Removed that line and now everything works. Just need to put some sort of exit Lua command after each door toggle and hopefully voila. You can use ipc.exit() to terminate the lua thread. John
Verybumpy Posted October 31, 2021 Author Report Posted October 31, 2021 Thank you kindly ! With your paid for product, and help, I'm now a happy camper and fixed the DC-6's shortcomings. If anyone is interested, much of the newbie Lua code I made is posted in my Avsim thread here... https://www.avsim.com/forums/topic/594234-pmdg-dc-6-force-mapping-fsx-keyboard-and-control-functions/ 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now