Difference between revisions of "DCS func getUnits"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
 
|desc= Returns a table of unit objects indexed in unit order. Useful for getting unit specific data for every unit in the group.  
 
|desc= Returns a table of unit objects indexed in unit order. Useful for getting unit specific data for every unit in the group.  
  
|rtnType= table
+
|rtnType= table of [[DCS_Class_Unit|Unit]] objects
  
 
|rtnExample=  
 
|rtnExample=  
Line 39: Line 39:
 
|related=  
 
|related=  
 
[[DCS_Class_Group|'''Group Functions:''']] {{listOfScriptingGroupFuncs}}
 
[[DCS_Class_Group|'''Group Functions:''']] {{listOfScriptingGroupFuncs}}
|notes=  
+
|notes= For train groups, getUnits() will always return just a single unit, regardless of the number of carriages in the train.
 
}}
 
}}
 
[[Category:Class Functions|getUnits]]
 
[[Category:Class Functions|getUnits]]
 +
[[Category:Game Patch 1.2.0|getUnits]]

Latest revision as of 01:51, 6 January 2023

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.