Mt5_Roie Posted November 27, 2012 Posted November 27, 2012 Goal: I want to be able to have some checks when a user click on the keyboard/joystick command for StartEngines or StopEgnines. Currently with the code there are several systems that must be on (fuel, battery, generators) before the engine can be started. But if a user just uses the keyboard/joystick command - it bypasses all that and starts the engine. So I started by adding the following to commands_defs: Keys = { iCommandEnginesStart = 309, iCommandEnginesStop = 310, } I then added some code to a device that I'd like to run the checks in: Declare the inits: local dev = GetSelf() local iCommandEnginesStart = 309 local iCommandEnginesStop = 310 Then I ran the listener: dev:listen_command(iCommandEnginesStart) dev:listen_command(iCommandEnginesStop) I then put the following code in the SetCommand: function SetCommand(command,value) if command == iCommandEnginesStart then print_message_to_user("ENGINE START DETECTED",5) end if command == iCommandEnginesStop then print_message_to_user("ENGINE STOP DETECTED",5) end end Initially I just wanted to make sure that it was detected and then add the code for the checks. But it doesn't seem to be hitting this SetCommand code. Am I missing a step? Ideally I would like to assign keyboard/joysticks command to devices to check things. Am I on the right track? Coder - Oculus Rift Guy - Court Jester
SkateZilla Posted November 27, 2012 Posted November 27, 2012 i hope ED can ship me some aleeve if/when we get a 3rd party dev NDA, My head hurts from pounding it on the desk. have you tried function SetCommand(command,value) if command == 309 then print_message_to_user("ENGINE START DETECTED",5) end if command == 310 then print_message_to_user("ENGINE STOP DETECTED",5) end end Windows 10 Pro, Ryzen 2700X @ 4.6Ghz, 32GB DDR4-3200 GSkill (F4-3200C16D-16GTZR x2), ASRock X470 Taichi Ultimate, XFX RX6800XT Merc 310 (RX-68XTALFD9) 3x ASUS VS248HP + Oculus HMD, Thrustmaster Warthog HOTAS + MFDs
Mt5_Roie Posted November 27, 2012 Author Posted November 27, 2012 (edited) Just tried it - no cluck. I even added: print_message_to_user(string.format("AVIONICS SetCommand Pressed: %i",command)) Right below the SetCommand line to see if anything is passed to the function and nothing. Doesn't seem like the listener is working. EDIT: Btw, the same code is used in DCS World\Scripts\Aircraft\_Common\Cockpit\Macro_Handler.lua so wonder why my version doesn't work, Edited November 27, 2012 by roiegat Coder - Oculus Rift Guy - Court Jester
aaron886 Posted November 28, 2012 Posted November 28, 2012 Sort of? You want to define your own buttons. Remove the default ones from the input LUAs and create your own using them as a template.
Mt5_Roie Posted November 28, 2012 Author Posted November 28, 2012 I tried that as well but ran into a problem. I started by removing the flap, gear, and airbrake section of the input LUA and using the devices buttons like on the P51 input file. The problem is that it tries to add the orignal ones back to the LUA file. I found out that there is a standard LUA file in the DCS folder and when it creates a new LUA file for joysticks or other devices, it grabs it from there. So I would have the settings I put in for flaps, gear, and airbrake - but also the ones it added, which would cause confusion. Sort of? You want to define your own buttons. Remove the default ones from the input LUAs and create your own using them as a template. Coder - Oculus Rift Guy - Court Jester
SilentEagle Posted November 28, 2012 Posted November 28, 2012 (edited) I tried that as well but ran into a problem. I started by removing the flap, gear, and airbrake section of the input LUA and using the devices buttons like on the P51 input file. The problem is that it tries to add the orignal ones back to the LUA file. I found out that there is a standard LUA file in the DCS folder and when it creates a new LUA file for joysticks or other devices, it grabs it from there. So I would have the settings I put in for flaps, gear, and airbrake - but also the ones it added, which would cause confusion. You would need to remove the keys from your keyboard.lua and your default.lua in your keyboard folder. I don't think it should add in the original key then. Make sure you also add your new command into the default.lua as this is where your game looks to setup commands for brand new users who don't have a setup yet. Also, if you plan on using an EFM with this aircraft, you would be wasting your time with key commands right now (which is what I did, originally) as most of the default key commands do nothing at all when the aircraft functions are being run through an EFM. You can use the default commands to make those checks and determine if the engine should start. Only with SFM do you need this workaround. Edited November 28, 2012 by SilentEagle 1
Mt5_Roie Posted November 28, 2012 Author Posted November 28, 2012 That is good to know. Will test it out this week sometime. Thanks SilentEagle. Coder - Oculus Rift Guy - Court Jester
Recommended Posts