Difference between revisions of "MIST getUnitsInPolygon"

From DCS World Wiki - Hoggitworld.com
m (Grimes moved page MIST getUnitsInPoly to MIST getUnitsInPolygon without leaving a redirect: Mixup on the function and page name.)
 
Line 1: Line 1:
 
{{Mission Scripting
 
{{Mission Scripting
  
|fName= mist.getUnitsInPolyZone|
+
|fName= mist.getUnitsInPolygon|
  
 
|vNum = Mist 3.5
 
|vNum = Mist 3.5
Line 35: Line 35:
 
|rtnExamples= unitNameTable
 
|rtnExamples= unitNameTable
  
|example= <code>
+
|example= The following will generate a message of the unit names of blue helicopters that are inside a polygon zone designated by the points of a route belonging to a group "weirdShapeLZ".
do
+
<pre>
--code needed
+
 
end
+
    local LZ = mist.getGroupPoints("weirdShapeLZ")
</code>
+
    local choppas = mist.makeUnitTable({"[blue][helicopter]"})
 +
    local inZone = mist.getUnitsInPolygon(choppas , LZ)
 +
    local msg = {"The following helicopters are in the landing zone: "}
 +
    for i = 1, #inZone do
 +
      msg[#msg+1] = inZone[i]:getName()
 +
      msg[#msg+1] = "\n"
 +
    end
 +
    trigger.action.outText(table.concat(msg), 20)
 +
</pre>
  
 
|notes= Units must be activated to be counted as inside the zone.
 
|notes= Units must be activated to be counted as inside the zone.
Line 46: Line 54:
  
 
}}
 
}}
[[Category: MIST|getUnitsInPoly]]
+
[[Category: MIST|getUnitsInPolygon]]

Latest revision as of 23:08, 19 January 2023


mist.getUnitsInPolygon

Added with: Mist 3.5
Description
Returns a table of units from the table unitNameTable that are inside of the polygon zone.
Syntax
table mist.getUnitsInPolygon(table unitNameTable ,table poly , number maxAlt )
Valid Input Values:
unitNameTable: mist.makeUnitTable({"[blue][helicopter]"})

poly: mist.getGroupPoints('polyPath1')

maxAlt: 200

Return value:
table
Return example:
unitNameTable
Usage Examples:
The following will generate a message of the unit names of blue helicopters that are inside a polygon zone designated by the points of a route belonging to a group "weirdShapeLZ".

    local LZ = mist.getGroupPoints("weirdShapeLZ")
    local choppas = mist.makeUnitTable({"[blue][helicopter]"})
    local inZone = mist.getUnitsInPolygon(choppas , LZ)
    local msg = {"The following helicopters are in the landing zone: "}
    for i = 1, #inZone do
       msg[#msg+1] = inZone[i]:getName()
       msg[#msg+1] = "\n"
    end
    trigger.action.outText(table.concat(msg), 20)
Notes:
Units must be activated to be counted as inside the zone.
Related Functions
makeUnitTable, getRandPointInCircle, getRandomPointInZone, getRandomPointInPoly, isTerrainValid, terrainHeightDiff, getUnitsInZones, getUnitsInMovingZones, pointInPolygon, getUnitsInPolygon, getDeadMapObjsInZones, getDeadMapObjsInPolygonZone, getUnitsLOS, random, randomizeNumTable, getAvgPoint, getQFE, getWindBearingAndVel, getPathLength, getPathInSegments, getPointAtDistanceOnPath, projectPoint, getGroupsByAttribute, , getUnitsByAttribute, mapValue,

Scripting Engine

MIST Root Page