Jump to content

G940 Leds - working program :)


Recommended Posts

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

Hi again,

 

I cleaned up the code a lot more. Now only one udp packet is sent per update.

Also changed the colors slightly (Green and Amber for 7.62mm / Rockets, Amber for Emergency Governour). Master Caution now blinks ;)

 

Attached a zipfile with updated script, and G940Leds.exe for convenience.

 

Greetings,

Frostregen

 

PS: Video of system in action:

HueyScript_G940Leds.zip


Edited by Frostregen
Link to comment
Share on other sites

Is there a way in the Export.lua to distinguish the aircraft that I am flying? I use the G940Leds for the Ka-50 and thus I could not use the code for the Huey there - would probably end in a huge mess as the device IDs are not unique but helo dependant.

 

So, how can I tell if I am dealing with a Huey cockpit or a Blackshark cockpit in the Export.lua?

Link to comment
Share on other sites

Is there a way in the Export.lua to distinguish the aircraft that I am flying? I use the G940Leds for the Ka-50 and thus I could not use the code for the Huey there - would probably end in a huge mess as the device IDs are not unique but helo dependant.

 

So, how can I tell if I am dealing with a Huey cockpit or a Blackshark cockpit in the Export.lua?

 

local acftName = "NONE"
local selfData = LoGetSelfData()
if selfData then
	acftName = selfData["Name"]
end

 

For the Huey, the name will be "UH-1H", I don't know for the Black Shark (probably "Ka-50").

Link to comment
Share on other sites

Ian;2272060']
   local acftName = "NONE"
   local selfData = LoGetSelfData()
   if selfData then
       acftName = selfData["Name"]
   end

For the Huey' date=' the name will be "UH-1H", I don't know for the Black Shark (probably "Ka-50").[/quote']

Thanks! Works like a charm!

Link to comment
Share on other sites

Thanks for the info! I had the idea to check if it is really a huey at one point, but forgot about it ;)

 

I updated the script to check for the huey, and else do nothing.

(Codebase is prepared to simply check and implement logic for other aircraft too)

This should even support changing the aircraft ingame.

 

Greetings,

Frostregen

HueyScript_G940Leds_v2.zip

  • Like 1
Link to comment
Share on other sites

First thank you so much to all for knowing this stuff.

 

This is so cool, I've been using this program for years. First for FC2 then BS2 but finally I can use it for everything.

 

After I try to remember how all this works again:book:


Edited by Scarecrow
Link to comment
Share on other sites

Hi there was wondering if anyone could give me some pointers in my export.lua.

 

I'm just trying to get an indicator working for nose gear on the Ka50 to begin with.

 

-- Check for Ka50
       if acftName == "Ka-50" then
           ProcessSharkGameLogic(t)
           needLedUpdate = true
       end    

function ProcessSharkGameLogic(t)
   local Mainpanel = GetDevice(0)
   
   if MainPanel ~= 0 then
   
       -- Lit button returns 0.1 when active. 0.2 when depressed but not active. 0.3 when depressed and active
       -- Indicators returns between 0.0 to 1.0, mostly only 0.0 and 1.0 but for example gear_handle moves between them
       --         Indicators with continous values are marked as such)
       
       -- Auto-pilot buttons and switches
       local bankhold = MainPanel:get_argument_value(330) -- Lit button
           
       -- First, reset all to OFF
       SetAllLed(OFF)
       
       -- Now apply data to Leds
       SetLedC(4, GREEN, bankhold > 0.0)
       
   end    
end

Any help would be much appreciated.:)


Edited by Scarecrow
Link to comment
Share on other sites

Any help would be much appreciated.:)

I tried your code and I got an error in dcs.log saying something that LUA can not compare strings with numerical values.

 

Makes sense ... you use get_argument_str() which returns a string, but the SetLedC() condition compares that to a numerical value.

 

The Huey code uses get_argument_value instead. But that didn't work for me for some reason. When I called the function directly, LUA said it was an unknown global. When I called it in the form of Mainpanel:get_argument_value it always returned 0.0.

 

So I tried to use only strings in SetLedC-condition and compare the result of get_argument_str with string constant like "0.0" - but that did not work either, the condition never became true ...?

 

I am no LUA pro ... maybe someone else can take over from here?


Edited by Flagrum
  • Like 1
Link to comment
Share on other sites

I think your problem is case sensitivity:

 

local Mainpanel = GetDevice(0)

should be

 

local MainPanel = GetDevice(0)

The rest looks fine though :)

 

Greetings,

Frostregen

 

PS: I had the same issue with variables always seemingly beeing 1, or conditions always beeing true:

I simply did not know, LUA does NOT support "function overloading". So I had 2 methods "SetLed(nr, state) and SetLed(nr, state, condition)", but LUA always called the first one... doh ;) This is why it is now called "SetLedC"...

 

@Flagrun:

I would try to stay with numerical values. Much easier to work with. Maybe show your code which did not work out? Else try to log out as much as you can to find the problem. (something like: G940Socket:send("hello=statuslight: "..variablename)


Edited by Frostregen
Link to comment
Share on other sites

PS: I had the same issue with variables always seemingly beeing 1, or conditions always beeing true:

I simply did not know, LUA does NOT support "function overloading". So I had 2 methods "SetLed(nr, state) and SetLed(nr, state, condition)", but LUA always called the first one... doh ;) This is why it is now called "SetLedC"...

 

It worked! You've made my day:D I could kiss you.

 

I have no idea what any of the above means, I'm just a monkey of moderate intelligence who wishes to ape your example. I understand "if then and else" logic and that is about the limit of my programming knowledge.

 

This drove me totally nuts all yesterday:doh:


Edited by Scarecrow
Link to comment
Share on other sites

  • 3 months later...

Hello.

I'm totally new to the DCS but i know that some things were changed in the few last years in it. Maybe i'll sound like i'm lazy and i don't like to bother with searching but i'm a bit overwhelmed with the all of information about this sim already.

I want to kindly ask you to show me the way how to proceed through the "installation" of this program/addon. At the moment i own only the Huey module on steam and i would like to use the script provided by Frostregen. The thing is that i have no idea where to put all of the lua files. In "readme" i see "Ka-50/config/" path but i cannot find the Huey one. I searched through every of "STEAM\SteamApps\common\DCSWorld" folder and found only one export.lua (38,6KB) in "DCWorld\Scripts" folder but there is no config.lua at all. What i did atm was to create "DCS/Scripts" folders (as there was no DCS too i had to create both of them) in "User/SavedGames".


Edited by Reyer
Link to comment
Share on other sites

Hello.

Maybe i'll sound like i'm lazy and i don't like to bother with searching.

The youth of today:no_sad:

 

Just joking.:D

 

Just use the files Frostregen provided, there is no config in the rar.

 

In your Windows Start menu click the button that has your account name and it 'll open a window with your personal files, the one you want is Saved Games/DCS in there.

 

 

The program G940 Leds can be put any where, it must be started before you start DCS World. It's tiny so I just leave it on the desktop.:)


Edited by Scarecrow
Didn't read your post properly Doh
Link to comment
Share on other sites

Thank you for the answer o/

I did as you said, before i even asked here, but it didn't worked. Then i tried to go back, download morg's package of G940Leds from 20'th post and follow the readme but i stuck on missing files/folders :/

Link to comment
Share on other sites

I don't think Morgs method works with DCS World. Svenvendevde re-wrote the Export for DCS world and multiplayer Ka50 usage. Then I think Frostregen used that as the basis for his Huey profile.

 

Aha. Well then the Export.lua you want to replace is the one in the Steam apps DCS/Scripts folder. This Scriptsfolder will contain a bunch of others as in the attached pic.

Scrpts.thumb.png.68a3512fb49edcc668aa518cf1363503.png

Link to comment
Share on other sites

I was afraid of replacing the export.lua file because of its size. Original is more than 11 times bigger and as i don't really know what is it doing i didn't wanted to break anything.

Sadly it didn't worked anyway :/

 

So, i'll tell what i did from the start, maybe i missed something that was obvious for everyone else but without it leds just won't work:

-Clean install of DCS World with huey module + changing settings/bindings to match script.

-Downloading Frostregen's zip file and unzipping it on desktop.

-Creating folder DCS in SavedGames and Scripts inside of it.

-Copying export.lua to SavedGames\DCS\Scripts

-Replacing export.lua in SteamApps\common\DCSWorld\Scripts with the one from zip file

-Starting the G940leds.exe from the desktop and launching game (logitech software is off; in second try i started udp_sender.exe from morg's zip too)

-Launching clean, custom mission with huey cold start so i'm able to check all things from the ground.

-Starting helo - turning on main generator, battery and then engine (in case that script won't work if helicopter is turned off)

-Checking buttons

 

When i connect g940 to the PC all leds go on but when i turn on G940leds.exe they are all going off.


Edited by Reyer
Link to comment
Share on other sites

Ok dokey. I had been shooting from the hip so to speak. Went in and had a look at the files.

 

First off if you ever think DCS World is broken you can run DCS Repair from the sart menu folder. You cannot break DCS it can heal itself. Actually I don't think steam supports that, once you're more confident look up the thread on "Unsteaming DCS".

 

The Export.lua is the one from Saved games that you should replace which you've done. The lights going off is normal when G940Leds detects a G940.

 

Try it again but this time after startup of the aircraft switch off the auto governor. I think maybe the profile has no lights on if you just do start up but switching off the AG will trip Master caution and the emergency governor LEDs.


Edited by Scarecrow
Cos I was wrong.
Link to comment
Share on other sites

Well...

I checked the governor too but still couldn't make it to work.

I downloaded non-steam version of DCS and copied export.lua once again to the savedgames\dcs\scripts folder. Still nothing. Replaced original export.lua in "DCS World\scripts". Still nothing. Created "config" folder in Uh-1H folder and copied there 4 lua files from morg zip file as it was said in readme. Still nothing.

I checked the export.lua content and there is some part of code that i suppose should send message to the G940leds.exe and print there "DCS World starting up!" when mission is starting up. But there is nothing in my case. After program finds my hotas all the time i see "Listening on port 33331" and nothing else after that. I think that this could mean that any of export.lua i placed nearly anywhere was not ran by game. I have no idea what to do now.


Edited by Reyer
Link to comment
Share on other sites

The fact that you had to create the User\SavedGames\DCS folder has got to be the problem.

 

I'm afraid I don't know why your install didn't create it, maybe be a steam thing?

 

Best thing to do is start a new thread in the General forum. Title it something like "Steam user export difficulty" explain your install didn't create Users\SavedGames\DCS so you don't know where to put your export.lua. Somebody in there will know.

 

Ignore Morgs files they are obsolete, just use Frostregens files.

 

Cos all you should have to do is drop in the export.lua, run G940LEDs and it should work.

 

I'm sorry I can't be of more help.


Edited by Scarecrow
Link to comment
Share on other sites

I've got my problem resolved already (some other game messed up things when created folder called SavedGames while folder that i was looking for was called by windows differently because of my windows language).

Thanks for your help guys o/

Link to comment
Share on other sites

  • 1 year later...

Is there any good soul, that would help me-stupid end user? I have that joystick, but have no knowledge enough to understand how to prepare function that would light buttons according to my mapping and rules that I've in head. I've had few attempts to prepare it, but effect was rather... pathetic.

I'd be extremely grateful for the one, who would support me with preparation of function that would work as follows:

P1 - green if laser is enabled, amber when laser is enabled and manual targeting mode is enabled, red if manual mode enabled but laser off, then off when manual off and laser off.

P2 - Burst length - green for short, amber for medium, red for long.

P5 - Cannon rate of fire - green for short, amber for long.

P6 - Cannon round type - green for HE, red for AP.

 

Then here comes autopilot stabilization, where:

P3 - Bank Hold

P4 - Pitch Hold

P7 - Heading Hold

P8 - Altitude Hold.

These should be green when enabled, if enabled and Flight Director mode on then amber, when in error mode then red blinking, and off when disabled.

 

Once again, I'll really appreciate any help.


Edited by Pipok

Natural Born Kamikaze

-------------------------

AMD Ryzen 5 3600, AMD Fatal1ty B450 Gaming K4, AMD Radeon RX 5700 XT, 32 GB RAM Corsair Vengeance LPX, PSU Modecom Volcano 750W, Logitech G940 HOTAS, Turtle Beach VelocityOne Rudder.

Link to comment
Share on other sites

  • 11 months later...

Is there an update on this install for KA-50?

running latest

DCS.1.5.7.7473.311

 

EDIT:

found a working export.lua

dated 2017 from PVI_Eagle

has all aircraft inside,

tested KA-50

left 4: weapons targeting (RED on/off)

right 4: autopilot (GREEN on/off)

 

https://forums.eagle.ru/showpost.php?p=3059069&postcount=5

 

direct link his export.lua

https://forums.eagle.ru/attachment.php?attachmentid=157780&d=1487757102


Edited by majapahit

| VR goggles | Autopilot panel | Headtracker | TM HOTAS | G920 HOTAS | MS FFB 2 | Throttle Quadrants | 8600K | GTX 1080 | 64GB RAM| Win 10 x64 | Voicerecognition | 50" UHD TV monitor | 40" 1080p TV monitor | 2x 24" 1080p side monitors | 24" 1080p touchscreen |

Link to comment
Share on other sites

  • 3 years later...
  • Recently Browsing   0 members

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