Jump to content

Recommended Posts

Posted

Hi my helpful fellow DCS trouble makers.

 

Is it possible to dynamically add trigger zones via LUA?

 

My intention is to load a LUA script on any existing mission so I can add 'modules' to missions without having to do it in the editor.

 

Thank you for reading,

 

Slazi(a)

Posted (edited)

Sure!

 

There are many ways to add trigger zones using lua.

When you use lua, a whole world opens with new possibilities.

 

I assume you are familiar with lua, as you're asking.

 

The low level APIs within DCS are documented at hoggit.

There you can find the definitions how to use trigger zones in lua.

 

http://wiki.hoggit.us/view/Simulator_Scripting_Engine_Documentation

 

namely here:

 

http://wiki.hoggit.us/view/DCS_func_getZone

 

But there isn't really an API to set new trigger zones.

Instead, there are frameworks that have created new types of zones!

 

These possibilities are endless ...

There are a couple of frameworks that you can use.

 

Grimes has listed them for you here:

http://wiki.hoggit.us/view/Simulator_Scripting_Engine_Documentation#Classes

 

If you like to develop procedural lua, and you don't have a lot of time, learn and use Mission Scripting Tools or MIST authored and managed by Grimes.

If you like to develop Object Oriented lua, and have some extra time to invest learning a larger framework, use MOOSE, which at the end provides you with a lot of extra stuff and faster implementations.

 

I suggest you have a look at this video that shows you how things are done the "MOOSE" way. The video is a bit old, but still valid.

 

 

You can try these things out yourself here by running one of these test missions:

 

https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ZON%20-%20Zones

 

Hopefully this helps!

 

If you like this and would like to use, please come back and send me a PM.

FC

Edited by FlightControl

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Posted

Thank you, flight. I will have to look into these for creating a trigger zone equivilent.

 

Right now I'm doing most of my testing through Witchcraft. I have a basic grasp of LUA and a good understanding of OOP, so perhaps MOOSE would be the best option.

 

I will try and post a code example once it runs in case others find this thread.

Posted

I'm running into a lot of issues already. I think I'll have to follow the tutorial again from scratch.

The MOOSE download directory structure didn't match the one given in the instructions.

Eclipse is crashing when reading the MOOSE.lua file and DCS is reporting errors when using the script.

 

I'm sure it's all my fault.

 

To be honest, all I need is the ability to add zones via a script.

Posted

I don't honestly know why you were expected to setup the dev environment just for this, OP.

Will it help to make one in MOOSE for you now or will it just mean you have more questions?

What type of zone do you want and what makes it dynamic? Is it going to move or is it just going to come on after some period of time or a trigger?

You can make a zone from a ME zone, a radius around a GROUP or a UNIT or a polygon zone based on the waypoints of a deactivated group.

here is the code for a radius around a UNIT:

https://github.com/FlightControl-Master/MOOSE_MISSIONS/blob/master/ZON%20-%20Zones/ZON-400%20-%20Radius%20Zone/ZON-400%20-%20Radius%20Zone.lua

 

All you need to do is download the latest moose.lua - make sure its a static one, not a dynamic (file size is tiny for a dynamic one) then load a script with some moose in it that does what you want.

 

Let me know if you need more help.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Posted

Thanks, Pikey. I've got the MOOSE environment working now in Eclipse. It's handy having all the autocompletes.

 

All I want to do is add a zone without having to define it in the ME. I want to add it entirely via LUA.

Posted

An example...

 

---
-- Name: ZON-500 - Polygon Zone
-- Author: FlightControl
-- Date Created: 18 Feb 2017
--
-- # Situation:
-- 
-- A ZONE_POLYGON has been defined, which boundaries are smoking.
-- A vehicle is driving through the zone perimeters.
-- When the vehicle is driving in the zone, a red smoke is fired from the vehicle location.
-- 
-- # Test cases:
-- 
-- 1. Observe the polygon perimeter smoke.
-- 2. Observe the vehicle smoking a red smoke when driving through the zone.

GroupInside = GROUP:FindByName( "Test Inside Polygon" )
GroupOutside = GROUP:FindByName( "Test Outside Polygon" )

GroupPolygon = GROUP:FindByName( "Polygon A" )

PolygonZone = ZONE_POLYGON:New( "Polygon A", GroupPolygon )
PolygonZone:SmokeZone( SMOKECOLOR.White, 20 )

Messager = SCHEDULER:New( nil,
 function()
   GroupInside:MessageToAll( ( GroupInside:IsCompletelyInZone( PolygonZone ) ) and "Inside Polygon A" or "Outside Polygon A", 1 )
   if GroupInside:IsCompletelyInZone( PolygonZone ) then
     GroupInside:GetUnit(1):SmokeRed()
   end
 end, 
 {}, 0, 1 )

More examples can be found here including demonstration missions that you can run.

 

https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/ZON%20-%20Zones

 

kind regards,

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Posted

Thanks, Flight. Actually, that's exactly the example that I looked at with this. I just need a good amount of time to look over what MOOSE is doing here.

 

Thank you for all the help and support so far. I really appreciate it.

  • Recently Browsing   0 members

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