Difference between revisions of "MIST getUnitsInZones"
From DCS World Wiki - Hoggitworld.com
| Line 5: | Line 5: | ||
|vNum = Mist 1.0 | |vNum = Mist 1.0 | ||
| − | |desc= Returns a table of | + | |desc= Returns a table of unit objects from the table unit_names that are inside any of the zones listed in the table of zone_names. | |
|rtnType= table | |rtnType= table | ||
| Line 37: | Line 37: | ||
| − | |rtnExamples= | + | |rtnExamples= |
| − | + | { [1] = { ["id_"] = 16779264,} ,[2] = { ["id_"] = 16780032,} ,[3] = { ["id_"] = 16780288,} ,[4] = { ["id_"] = 16780544,} ,} | |
| − | |||
| − | + | |example= Returns a table of units within the zone KutasiBattle and builds table of units index by the country each unit belongs to. | |
| − | u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'KutaisiBattle'}) | + | local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'KutaisiBattle'}) |
| + | local countries = {} | ||
| + | for i = 1, #u do | ||
| + | local cntry = Unit.getCountry(u[i]) | ||
| + | if not countries[cntry] then | ||
| + | countries[cntry] = {} | ||
| + | end | ||
| + | table.insert(countries[cntry], u[i]) | ||
| + | end | ||
| − | |||
| − | |||
| − | |||
|notes= Is called by and is related to [[Units in zones]] | |notes= Is called by and is related to [[Units in zones]] | ||
Latest revision as of 00:12, 4 January 2021
mist.getUnitsInZones
| Added with: Mist 1.0 |
| Description |
| Returns a table of unit objects from the table unit_names that are inside any of the zones listed in the table of zone_names. |
| Syntax |
| table mist.getUnitsInZones(UnitNameTable unit_names ,table zone_names , string zone_type ) |
| Valid Input Values: |
ExampleUnitNameTable
zone_names = {'zone1', 'zone2'}
zone_type = 'cylinder' - cylindrical shaped zone extending to +/- infinity in altitude. 'sphere' - spherical zone |
| Return value: |
| table |
| Return example: |
| { [1] = { ["id_"] = 16779264,} ,[2] = { ["id_"] = 16780032,} ,[3] = { ["id_"] = 16780288,} ,[4] = { ["id_"] = 16780544,} ,} |
| Usage Examples: |
Returns a table of units within the zone KutasiBattle and builds table of units index by the country each unit belongs to.
local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'KutaisiBattle'})
local countries = {}
for i = 1, #u do
local cntry = Unit.getCountry(u[i])
if not countries[cntry] then
countries[cntry] = {}
end
table.insert(countries[cntry], u[i])
end
|
| Notes: |
| Is called by and is related to Units in zones |
| 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, |
