Jump to content

Add a zone with script?


marcost

Recommended Posts

I've searched and read, but can't find how to do this with DCS lua or MIST (even though similar questions were pointed in this direction).

I want to be able to create trigger zones with a script rather than ME. Why? Because I can then import them into other pre-existing missions using the same map.  

I will know what the x & y co-ordinates and radius need to be. I just need to know if it can be created within a script?

 

Pseudo-code:

CreateZone{
x = 1000
y = 2000
z = 0
radius = 3000
name = myZone}

Thanks

M

W10 64

I7 4790k o/c to 4.6Ghz

Asus Maximus Ranger VII

24gb DDR3 RAM @ 2133

Asus Strix 1080ti OC

ASUS ROG G-sync 27" monitor

DCS on M2 drive Samsung 960 Pro

MS FFB2 with F-16 grip

CH pro throttle

MFG Crosswind pedals

TrackIR 5

3 x Bodnar button & axis boxes

Link to comment
Share on other sites

There actually is an addZone function in the simulator scripting engine, however I've never been told the syntax for it, thus it remains undocumented. 

That said it doesn't really matter because with scripting the things you'd use it for can be done with simple math for the coordinates and radius anyway. 

  • Like 1

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

Thanks both,

You put me on the right path, especially with the fact that only co-ordinates are required. I'm now a MIST user!

 

Regards,

M

W10 64

I7 4790k o/c to 4.6Ghz

Asus Maximus Ranger VII

24gb DDR3 RAM @ 2133

Asus Strix 1080ti OC

ASUS ROG G-sync 27" monitor

DCS on M2 drive Samsung 960 Pro

MS FFB2 with F-16 grip

CH pro throttle

MFG Crosswind pedals

TrackIR 5

3 x Bodnar button & axis boxes

Link to comment
Share on other sites

Here is how I add zone's using the SSE 'addZone' function, hope this helps;

local function add_zone(name, x, y, radius)
  if trigger.misc.getZone(name) then return trigger.misc.getZone(name) end
  return trigger.misc.addZone
  {
    ["name"] = name,
    ["y"] = y,
    ["x"] = x,
    ["radius"] = radius,
    ["properties"] =
    {
      [1] =
      {
        ["key"] = name,
        ["value"] = "",
      },
    },
    ["color"] = {0,0,0,1},
    ["hidden"] = false,
  }
end

local new_zone = add_zone(zone.name, zone_position.x, zone_position.z, zone.size)

 


Edited by PravusJSB
  • Thanks 2

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

Link to comment
Share on other sites

It does, thank you!

W10 64

I7 4790k o/c to 4.6Ghz

Asus Maximus Ranger VII

24gb DDR3 RAM @ 2133

Asus Strix 1080ti OC

ASUS ROG G-sync 27" monitor

DCS on M2 drive Samsung 960 Pro

MS FFB2 with F-16 grip

CH pro throttle

MFG Crosswind pedals

TrackIR 5

3 x Bodnar button & axis boxes

Link to comment
Share on other sites

  • 3 months later...
On 7/15/2022 at 3:11 PM, PravusJSB said:

Here is how I add zone's using the SSE 'addZone' function, hope this helps;

local function add_zone(name, x, y, radius)
  if trigger.misc.getZone(name) then return trigger.misc.getZone(name) end
  return trigger.misc.addZone
  {
    ["name"] = name,
    ["y"] = y,
    ["x"] = x,
    ["radius"] = radius,
    ["properties"] =
    {
      [1] =
      {
        ["key"] = name,
        ["value"] = "",
      },
    },
    ["color"] = {0,0,0,1},
    ["hidden"] = false,
  }
end

local new_zone = add_zone(zone.name, zone_position.x, zone_position.z, zone.size)

 

 

How did you find out about this function? I can't even find reference to the 'misc' list of commands. I'd really appreciate it if you could explain how you worked this out so I can do the same. Thanks.

Link to comment
Share on other sites

  • 10 months later...
On 7/16/2022 at 12:11 AM, PravusJSB said:

Here is how I add zone's using the SSE 'addZone' function, hope this helps;

local function add_zone(name, x, y, radius)
  if trigger.misc.getZone(name) then return trigger.misc.getZone(name) end
  return trigger.misc.addZone
  {
    ["name"] = name,
    ["y"] = y,
    ["x"] = x,
    ["radius"] = radius,
    ["properties"] =
    {
      [1] =
      {
        ["key"] = name,
        ["value"] = "",
      },
    },
    ["color"] = {0,0,0,1},
    ["hidden"] = false,
  }
end

local new_zone = add_zone(zone.name, zone_position.x, zone_position.z, zone.size)

 

 

Awesome function mate. Is there a removeZone as well?

Also, what is "SSE"?


Edited by OzDeaDMeaT

CPU: i9-12900K @ 4.9Ghz

M/B: MSI MEG z690 Ace

RAM: 128GB

Video Card: MSI RTX 4090 Suprim Liquid X

VR: Varjo Aero

Link to comment
Share on other sites

  • Recently Browsing   0 members

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