Jump to content

Beginner script format assistance


Recommended Posts

Posted
Anyone that can help me with a script that gives me a message and/or sound when any airplane goes below certain altitude AGL in a certain trigger zone?

It needs to monitor continuously.

 

Would be much appreciated.

 

 

Do you specifically need a script or will a conventional mission editor trigger do the trick?

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

The conventional ME triggers only can check for MSL altitude.

But basically any script, triggers or mix of both will do.

dUJOta.jpg

 

Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro

Posted
@ArturDCS, try something like this:

Thanks! I can see the exceptions now.

Posted
The conventional ME triggers only can check for MSL altitude.

But basically any script, triggers or mix of both will do.

 

Ah! Well in that case I can provide you with the pertinent trigger system but all your zones will have to be over the water. ;)

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

Hehe.

If it was that easy, I still could do it.

It's the AGL part that bugs me.

Unless I make a target range Waterworld style.

dUJOta.jpg

 

Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro

Posted
Object.destroy(Group.getByName('groupname'))

 

or

 

Group.getByName('group'):destroy()

 

If anyone is trying to do something similar to what I was- with a dynamically added unit- I thought I'd mention that the latter example worked... the first one didn't but I'm not sure why...

 

 

Hehe.

If it was that easy, I still could do it.

It's the AGL part that bugs me.

Unless I make a target range Waterworld style.

 

Only if Kevin Costner is one of the targets.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

Is it possible to stop infantry (unit or group)? They have a route/path and are moving. How do I stop them from Lua?

Posted
Give them a new task?

Yes so it seems, as part found in your script. Thanks for pointing the direction.

local _controller = Group.getByName(_groupName):getController();
_controller.resetTask()

Posted

Looking to do a countdown timer... I found this post from Grimes helping me out with a different problem-

 

http://forums.eagle.ru/showpost.php?p=1690229&postcount=5

 

 

Other than the blue / red plus score continuous triggers- this is what the scripts look like:

 

do

redScore = 0

blueScore = 0

 

function convert(val)

local min = 0

if val > 0 then

while val >= 60 do

val = val - 60

min = min + 1

end

end

msg = {}

msg[#msg+1] = min

msg[#msg+1] = ':'

if val < 10 then

msg[#msg+1] = 0

end

msg[#msg+1] = val

 

return table.concat(msg)

end

end

 

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

 

display = {}

display[#display + 1] = 'Red team time in zone: '

display[#display + 1] = convert(redScore)

display[#display + 1] = '\n'

display[#display + 1] = 'Blue team time in zone: '

display[#display + 1] = convert(blueScore)

 

trigger.action.outText(table.concat(display), 2)

 

I'm wondering if someone has something that is just a countdown from 5 minutes to 0... and post it up so all can see it. Is there something more condensed that could be used?

 

I've redded out some code I'd look at removing just to get the timer working... am I in the ballpark?

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

I have a group of units. How do I kill one of the units in the group using Lua?

I do not want affect the surroundings or other units at all.

Posted
Object.destroy(Group.getByName('groupname'))

 

or

 

Group.getByName('group'):destroy()

 

Like this ^ but switch out Group with Unit...

 

This will make it cease to exist... not sure if you just want to explode the unit?

 

You can do that with a trigger too.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted
Like this ^ but switch out Group with Unit...

This will make it cease to exist... not sure if you just want to explode the unit?

You can do that with a trigger too.

Yes just want it too cease to exist.

Where is it listed, the function Unit.Destroy()?

 

I will try this.

Posted

Steve recommended it in an earlier post- I haven't seen it over in the wiki or anything but I'm assuming it's there.

 

If it's a dynamically added unit I found I had more luck (with Group) on the bottom option... try both- maybe they'll both work for your purposes.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted
Steve recommended it in an earlier post- I haven't seen it over in the wiki or anything but I'm assuming it's there.

Well I cannot find it. It's not the first time I see stuff used that are not listed anywhere.. Haven't tried it yet.

Posted

How do I get a list/table of countries belonging to a coalition? BLUE/RED/NEUTRAL

Posted
Yes for whats its worth. It sure could be more elaborate.

 

For example Group.Destroy(). There is a tiny mention of group:destroy() but only as a side note. Not what it means or any explanations.

So a search for Group.Destroy() does not give any hits.

An example:

Group.destroy(Group.getByName("My group"))

http://en.wiki.eagle.ru/wiki/Simulator_Scripting_Engine/DCS:_World/Part_2#Group

 

 

 

How do I get a list/table of countries belonging to a coalition? BLUE/RED/NEUTRAL

You could iterate through all the units in the mission (for example using coalition.getGroups) and create a list from that. Are you sure this is something you need though?

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Posted
An example:

Group.destroy(Group.getByName("My group"))

http://en.wiki.eagle.ru/wiki/Simulator_Scripting_Engine/DCS:_World/Part_2#Group

Aaargh. Did I do so sloppy searching I didn't see this? I blame it on being tired. :music_whistling:

 

You could iterate through all the units in the mission (for example using coalition.getGroups) and create a list from that. Are you sure this is something you need though?

Yes I could do that. Would be needed once and then stored as these wouldn't change. Yes I might need it. I don't remember for what. I will tomorrow, right now my brain feels like a squeezed lemon.

Tomorrow is a new day!

 

Today I have been coding the "classes" RescueeGroup and RescueHelicopter with relevant methods (functions).

 

:joystick:

Posted

Nice! Remember to take breaks though, I feel most of the time when I am stuck I just need to leave the computer for a while and then when I return everything is crystal clear what I need to do.

 

As for the documentation, AFAIK it's all created and maintained by a just one community member (Grimes or Speed, I don't remember who, sorry :( ). I do think its good and it's infinitely better to when we had no documentation :) Even so, it is a Wiki after all so there is nothing stopping the community from improving it I think. It could use some cross-linking and I must say I like the approach of the Bohemia Interactives wiki (https://community.bistudio.com/wiki/eyePos) with individual pages for each function so you can have examples and notes for example if a function is unstable on a specific version of DCS...

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Posted

I was trying the msg. function the other day but did not get the sound to play. Any thoughts on what this is about Ragnar?

 

local msg = {}
if msg.text == nil then
   msg.text = 'Message.' 
   msg.displayTime = 10  
   msg.msgFor = {coa = {'blue'}}
   msg.fileName = 'sound.ogg'

   mist.message.add(msg)
end    

The "sound.ogg" is played with a normal trigger first so the sound is in the mission file.

Posted

I just realize I left out the comma's :music_whistling:

 

I was trying the msg. function the other day but did not get the sound to play. Any thoughts on what this is about Ragnar?

 

Looks better this way maybe ;)

local msg = {}
if msg.text == nil then
   msg.text = 'Message.', 
   msg.displayTime = 10, 
   msg.msgFor = {coa = {'blue'}},
   msg.fileName = 'sound.ogg',

   mist.message.add(msg)
end    

The "sound.ogg" is played with a normal trigger first so the sound is in the mission file.

Posted

No, that was not it. Tried this as well. No sound is playing but the message shows up.

 

-- message 1: message to all
local msg = {} 

if msg.text == nil then
   msg.text = "TO ALL: Hello World" 
   msg.displayTime = 10
   msg.msgFor = {coa = {'all'}}
   msg.Name = "test"
   msg.fileName = "sound.ogg"

   mist.message.add(msg)
end

Posted

You could iterate through all the units in the mission (for example using coalition.getGroups) and create a list from that. Are you sure this is something you need though?

 

I found the following in MiST. I haven't tried it yet. Undocumented function?

 

coalition.getCountryCoalition(countryId)

  • Recently Browsing   0 members

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