Jump to content

GreyEcho

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by GreyEcho

  1. So, for those who are interrested, I solved the problem by changing this line c.setpeername(host,dstport) into this c:setpeername(host,dstport) It seems to work so far, I'll post my full Export.lua when I am done.
  2. Hello ! Newcomer here ! I own a G940 HOTAS, which I quite like. It does have some leds on the throttle, and I'd love to see them switch on and off depending on what's going on in the simulation. I play FC3, and the Su27 primarily. I saw this thread : http://forums.eagle.ru/showthread.php?t=45895&highlight=G940 It is a program which listen on UDP port 33331, waiting for some specific commends, and switches the leds accordingly (Red, Green, Amber or Off). The program does work, I tested it with the udp_sender program (which sends strings on UDP localhost 33331) But the Export.lua provided is old and is designed to work with Black Shark 2. So I'm trying to write my own Export.lua, and I spent way too much time on it for no result :( For the beginning, I'm just trying to have the P6 light green if the left engine RPM is higher than 0, otherwise, light it Amber. The commends I send to G940leds.exe on UDP localhost 33331 are : SetAll=; SetOneGreen=; SetOneAmber=; Hello= Bye= My Export.lua so far: local default_output_file = nil function LuaExportStart() package.path = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua" package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll" socket = require("socket") host = "localhost" dstport = "33331" c = socket.udp() c.setpeername(host,dstport) c:send("Hello=DCS WORLD is sending data") c:send("SetAll=o;") end function LuaExportBeforeNextFrame() end function LuaExportAfterNextFrame() local EngineInfo = LoGetEngineInfo() local MechInfo = LoGetMechInfo() local AP = LoGetNavigationInfo() local State = LoGetMCPState() if(EngineInfo.RPM.left > 65) then c:send("SetOneGreen=6;") else c:send("SetOneAmber=6;") end end function LuaExportStop() if default_output_file then default_output_file:close() default_output_file = nil end c:send("SetAll=o;") c:send("Bye=DCS World has stop sending data") c:close() end function LuaExportActivityNextEvent(t) local tNext = t return tNext end And here are the relevant part of the dcs.log file : [...] 00019.960 ERROR Lua::Config: Call error LuaExportStart:[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:61: bad argument #1 to 'setpeername' (udp{any} expected) stack traceback: [C]: ? [C]: in function 'setpeername' [string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:61: in function <[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:22>. [...] 00038.082 ERROR Lua::Config: Call error LuaExportStop:[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:119: calling 'send' on bad self (udp{connected} expected, got userdata) stack traceback: [C]: ? [C]: in function 'send' [string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:119: in function <[string "C:\Users\Hugues\Saved Games\DCS\Scripts\Export.lua"]:111>. [...] Obviously the lines number don't correspond, but the first problem is this line : c.setpeername(host,dstport) and the second one is this one : c:send("SetAll=o;") Thank you very much for taking the time to read me and help me ! - GreyEcho
×
×
  • Create New...