Jump to content

Recommended Posts

Posted

There seems to be a distinct lack of any tutorials with LUA within DCS A10. Basically what I'm looking to do is read in some strings via serial connection to a Teensy microcontroller I'm using and change switches in-game based on this. (The reason I want to do this is because the alternatives, which are emulating a joystick, 32-button limit is an issue, or emulating a keyboard, where I can't separate input from my normal keyboard).

 

Now I can go online and look at LUA documentation to find out how to read in the strings, but I can't find any documentation on how to set switches in-game via LUA, for example, setting the GUNPAC switch to ARMED. Any help would be -greatly- appreciated as this would solve all my interfacing issues with the flight-panel I'm working on.

 

NOTE: I'm currently on vacation so I only have internet when passing through a marina with wifi. I probably won't have internet for the next few days short of some random luck.

Posted

Get the device where the switch you want to manipulate resides. In this case for GUN/PAC switch is on the AHCP.

 

So in [your DCS folder]\Scripts\Aircrafts\A-10C\Cockpit\devices.lua find the line:

devices["AHCP"] = counter()--7

Note the number "7" at the end. That is the device ID of the AHCP. Then in [your DCS folder]\Scripts\Aircrafts\A-10C\Cockpit\clickabledata.lua find the AHCP section and then locate the line for the GUNPAC switch:

 

elements["PNT-TMB-AHCP-GUNPAC"] = 
 {class =
    {class_type.TUMB,class_type.TUMB},
     hint  = _("Gun Arm Mode"),
     device = devices.AHCP,
     action = {device_commands.Button_2,device_commands.Button_2},
     arg = {376,376},
     arg_value = {0.1,-0.1},
     arg_lim = {{0.0, 0.2},{0.0, 0.2}}
   }

Note the "action" line "Button_2". The ID of the button is 3000 + the "2" so 3002.

 

The arg_value = {0.1, -0.1}, arg_lim={{0.0,0.2},{0.0,0.2}} means to add 0.1 up to a limit of 0.2 for each left click or subtract 0.1 down to a limit of 0.0 for each right click.

 

In your Export.lua, to set the button position you do the following:

 

--get the device...
ahcp = GetDevice(7) --the AHCP device ID

--set which switch to manipulate
gunpac_switch = 3002 --the GUN/PAC switch ID

--set the position you want
switch_pos_down = 0.0 --switch down for GUNARM
switch_pos_mid = 0.1 --switch middle for SAFE
switch_pos_up = 0.2 --switch up for GUN/PAC

--perform the actual "click" up to GUN/PAC
ahcp:performClickableAction(gunpac_switch, switch_pos_up)

--or safe...
ahcp:performClickableAction(gunpac_switch, switch_pos_mid)

--or down for GUNARM...
ahcp:performClickableAction(gunpac_switch, switch_pos_down)

See Gadroc's Export.lua which really was really the key to my understanding after much searching. Also see Export 101 from the ED wiki. It's geared more towards BS but the principles are the same.

Posted

Thanks a ton, now I just need to solve the LUA serial issues, or rather the COMPLETE lack there-of. Oh well, guess I'll have to write a script in another language to parse info for the LUA script :(

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...