DCS func getUnits

From DCS World Wiki - Hoggitworld.com
Revision as of 01:51, 6 January 2023 by Loophole 62ndFF (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Scripting Root

Envrioment: Mission Scripting
Function: getUnits Added with: 1.2.0
Member Of: Group
Syntax: table of Unit objects Group.getUnits(Class Self )
Description: Returns a table of unit objects indexed in unit order. Useful for getting unit specific data for every unit in the group.


Return Value: table of Unit objects
Return Example:
Examples: The following would run a function if any of the aircraft in the groups fuel level is below 10%
for index, data in pairs(Group.getByName('CAP1'):getUnits())
 if Unit.getFuel(data) < 0.1 then
   abortMission('CAP1')
 end 
end
Related Functions: Group Functions: isExist, activate, destroy, getCategory, getCoalition, getName, getID, getUnit, getUnits, getSize, getInitialSize, getController, enableEmission
Notes: For train groups, getUnits() will always return just a single unit, regardless of the number of carriages in the train.