Jump to content

Someone willing to give a jumpstart for LUA steps?


Don Rudi

Recommended Posts

Hi,

 

I published a couple of missions so far and would like to take my next missions to a new level by using LUA scripts. For starters I would love to have a simple script returning TRUE if an aircraft (myAircraft) is painted by SAM site's radar (myRadar) (preferebly the tracking radar).

I found snippets and a huge script, but both are a riddle as I have zero LUA experience so far.

 

Fear not, I am not a doofy, I earn my living with script programming. I just need a jump start for LUA/DCS. Any fine fellow mission builder willing to help and push me into the right direction?

 

Thanks

Carsten


Edited by Don Rudi

Modules: all, except for the Dora

My missions: https://www.digitalcombatsimulator.com/en/files/filter/user-is-Don rudi/apply/

Primary system: i7-13700k, RTX 4080, 32 GB, Win 11, Virpil WarBRD + Constellation Alpha with 5cm extension, Virpil CM2 throttle, Virpil Ace Interceptor pedals, Virpil Rotor TCS base + Blackshark grip, Winwing Triple MFD and ICP, 34" UWHQD screen
Acer Nitro i7-10700, RTX 3060, 64 GB, Virpiel Rotor TCS base + Blackhawk grip, Virpiel Ace Torq pedals, 34" UWHQD screen

Link to comment
Share on other sites

That'd be perfect :) Just an example how this getDetected works, I (hope) I can go from there :)

Modules: all, except for the Dora

My missions: https://www.digitalcombatsimulator.com/en/files/filter/user-is-Don rudi/apply/

Primary system: i7-13700k, RTX 4080, 32 GB, Win 11, Virpil WarBRD + Constellation Alpha with 5cm extension, Virpil CM2 throttle, Virpil Ace Interceptor pedals, Virpil Rotor TCS base + Blackshark grip, Winwing Triple MFD and ICP, 34" UWHQD screen
Acer Nitro i7-10700, RTX 3060, 64 GB, Virpiel Rotor TCS base + Blackhawk grip, Virpiel Ace Torq pedals, 34" UWHQD screen

Link to comment
Share on other sites

This is a short part of the detection script from Mbot. Very cool script.

 

ewrUnit = Unit.getByName("EWR unitname")

 

ewrCtrl = ewrUnit:getGroup():getController()

local DetectedTargets = ewrCtrl:getDetectedTargets(RADAR)

 

Detectedtargets returns a list of detected.units by Radar. (Check what detection method you want to use, visual, radar, what type of radar)

 

So, since detected targets is a table of detected units, now compare it with your aircraft of interest. You have to develop the script...

 

Something like

 

For a,, b in pairs (detectedtargets) do

If detectedtargets[a] :getName() = "my plane"

Then....

 

Something like that.

 

Hope it helps


Edited by ESAc_matador
Link to comment
Share on other sites

I highly recommend anyone interested in DCS mission scripting to try MOOSE. I am a complete programming neophyte but am learning to develop some simple, yet powerful, scripts using the MOOSE framework. Check out some of the Youtube videos for setup and examples. The very helpful community hangs out at the MOOSE channel on Discord.

Link to comment
Share on other sites

I highly recommend anyone interested in DCS mission scripting to try MOOSE. I am a complete programming neophyte but am learning to develop some simple, yet powerful, scripts using the MOOSE framework. Check out some of the Youtube videos for setup and examples. The very helpful community hangs out at the MOOSE channel on Discord.

 

+1

 

its so worth it. Just go through the included sample missions and it will make sense even if you (like me) have no clue about programming

 

edit: start with the SPAWN sample missions, a real eye-opener

Link to comment
Share on other sites

Thanks for the help guys :)

Before falling back on something like moose, I'd like to figure out a few things on my own though :)

Guess I need to load a few sample scripts and go through them to see the correct syntax. But I am confident

Modules: all, except for the Dora

My missions: https://www.digitalcombatsimulator.com/en/files/filter/user-is-Don rudi/apply/

Primary system: i7-13700k, RTX 4080, 32 GB, Win 11, Virpil WarBRD + Constellation Alpha with 5cm extension, Virpil CM2 throttle, Virpil Ace Interceptor pedals, Virpil Rotor TCS base + Blackshark grip, Winwing Triple MFD and ICP, 34" UWHQD screen
Acer Nitro i7-10700, RTX 3060, 64 GB, Virpiel Rotor TCS base + Blackhawk grip, Virpiel Ace Torq pedals, 34" UWHQD screen

Link to comment
Share on other sites

I wouldn't use getdetectedtargets, as in my experience you can't get a useful unitname, or even a unitID from that.

When I tested it, I got something like

["id_"] = 167459

Can't remember the number but it was something like that.

The unit's actual Unitid was 2, lol.

I'd use istargetdetected, in which you give the unit you're looking for. This is a better solution if you're looking for one specific sensor seeing one specific unit, as it gives you "TRUE", so that's much simpler to use.

Link to comment
Share on other sites

I wouldn't use getdetectedtargets, as in my experience you can't get a useful unitname, or even a unitID from that.

When I tested it, I got something like

["id_"] = 167459

Can't remember the number but it was something like that.

The unit's actual Unitid was 2, lol.

I'd use istargetdetected, in which you give the unit you're looking for. This is a better solution if you're looking for one specific sensor seeing one specific unit, as it gives you "TRUE", so that's much simpler to use.

 

You get a bunch of unit objects. This code adds the unit name to a table named msg.

 

           for i, detected in pairs(_u:getDetectedTargets()) do
               msg[#msg+1] = '     \n ' .. Unit.getName(detected.object)
           end

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

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