I'm trying to export some data from DCS A-10C to get the LEDs on my G940 to light up based on in-game status settings. So far, I've gotten three of the LEDs to mimic the status of the gear indication lights using a bit of Lua code and morg's G940LED program for BS (http://forums.eagle.ru/showthread.php?t=45895) to control the LEDs themselves.
I'm having some difficulty trying to coax variables out of DCS. So far, I've worked out how to get indications from the main panel itself, but I am keen to use some of the simpler commands.
A simplified section of my code is below, to give you an idea of what I'm doing now. This is a coroutine which is run every 100ms:
function g940leds(t)
local tNext = t
local MainPanel = GetDevice(0)
local c = g940socketsetup() -- Sets up a socket for morg's G940leds.exe
while true do
local flap_posn = math.abs(MainPanel:get_argument_value(653))
local nose_gear = math.abs(MainPanel:get_argument_value(659))
local left_gear = math.abs(MainPanel:get_argument_value(660))
local right_gear = math.abs(MainPanel:get_argument_value(661))
if nose_gear == 1 then
c:send("SetLed=3g") -- Set LED 3 to be Green
else
c:send("SetLed=3o") -- Set LED 3 to be Off
end
if left_gear == 1 then
c:send("SetLed=7g") -- Set LED 7 to be Green
else
c:send("SetLed=7o") -- Set LED 7 to be Off
end
if right_gear == 1 then
c:send("SetLed=8g") -- Set LED 8 to be Green
else
c:send("SetLed=8o") -- Set LED 8 to be Off
end
if flap_posn < 0.05 then
c:send("SetLed=4o") -- If flaps are up, Set LED 4 to be Off
elseif flap_posn > 0.2 and flap_posn < 0.25 then
c:send("SetLed=4g") -- If flaps are at 7°, Set LED 4 to be Green
elseif flap_posn > 0.65 and flap_posn < 0.68 then
c:send("SetLed=4a") -- If flaps are at 20°, Set LED 4 to be Amber
else
c:send("SetLed=4r") -- If flaps are in travel or abnormal, Set LED 4 to be Red
end
tNext = coroutine.yield();
end
end
This is working fine for the time being, but I have noticed that there are some other functions in Export.lua which would make it easier to get more information out of the game. Eventually, I want to build an Android application so that I can use my phone in a similar way to some of the iPhone powered panels out there, so I will want to access some more complex info in the future.
A couple of examples of things that I can't use at the moment are:
LoGetMechInfo() -- This seems to have a lot of data which would be extremely useful, but whenever I try to use it, Lua returns 'nil'.
LoGetIndicatedAirspeed() appears to return nil.
Is anyone able to advise me whether these commands are correctly working in DCS, and if so, provide some example code on how to get data out of them?