entities: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Arma[ _]2(\|.*)\]\]" to "{{GameCategory|arma2|Scripting Commands}}")
m (variable naming ine xamples)
 
(34 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma2oa |Game name=
|game1= arma2oa
|version1= 1.60


|1.60|Game version=
|game2= tkoh
|version2= 1.00


|gr1= Object Detection |GROUP1=
|game3= arma3
____________________________________________________________________________________________
|version3= 0.50


| Returns a list of all alive and dead entities of the given type or deriving from the given type. Units in vehicles are ignored with the primary syntax.
|gr1= Object Detection
{{Informative | '''Optimisation tip''': Keep number of types in both ''includeTypes'' and ''excludeTypes'' arrays to a minimum by possibly using parent/base classes.<br>If you have to use several types, arrange them in order so that the more common types go at the beginning of the array.}} |DESCRIPTION=
____________________________________________________________________________________________


| [[entities]] type |SYNTAX=
|descr= Returns a list of all alive and dead entities of the given type or deriving from the given type. Units in vehicles are ignored with the primary syntax.
{{Feature|informative|'''Optimisation tip''': Keep number of types in both ''includeTypes'' and ''excludeTypes'' arrays to a minimum by possibly using parent/base classes.<br>If you have to use several types, arrange them in order so that the more common types go at the beginning of the array.}}


|p1= type: [[String]] - if an empty string <tt>""</tt> is provided, all entities are returned |PARAMETER1=
|s1= [[entities]] type


| [[Array]] |RETURNVALUE=
|p1= type: [[String]] - if an empty string {{hl|""}} is provided, all entities are returned
____________________________________________________________________________________________


|s2= [[entities]] [typesInclude, typesExclude, includeCrews, excludeDead] {{since|arma3|1.65.138685|y}} |SYNTAX2=
|r1= [[Array]]


|p21= typesInclude: [[Array]] - in format [type1, type2, ...typeN], where type is a [[String]]. Empty array [] means include every entity. Method used for filtering - [[isKindOf]] |PARAMETER21=
|s2= [[entities]] [typesInclude, typesExclude, includeCrews, excludeDead]


|p22= typesExclude: [[Array]] - in format [type1, type2, ...typeN], where type is a [[String]]. Empty array [] means exclude no entity. Method used for filtering - [[isKindOf]] |PARAMETER22=
|s2since= arma3 1.66


|p23= includeCrews: [[Boolean]] - (Optional, default [[false]]) include crews currently in vehicles |PARAMETER23=
|p21= typesInclude: [[Array]] - in format [type1, type2, ...typeN], where type is a [[String]]. Empty array [] means include every entity. Method used for filtering - [[isKindOf]]


|p24= excludeDead: [[Boolean]] - (Optional, default [[false]]) exclude dead entities |PARAMETER24=
|p22= typesExclude: [[Array]] - in format [type1, type2, ...typeN], where type is a [[String]]. Empty array [] means exclude no entity. Method used for filtering - [[isKindOf]]


|r2= [[Array]] |RETURNVALUE2=
|p23= includeCrews: [[Boolean]] - (Optional, default [[false]]) include crews currently in vehicles
____________________________________________________________________________________________


|x1= <code>_allcars = [[entities]] "Car";</code> |EXAMPLE1=
|p24= excludeDead: [[Boolean]] - (Optional, default [[false]]) exclude dead entities


|x2= Return all alive entities on the map:<code>_allalive = [[entities]] [<nowiki/>[], [], [[true]], [[true]]];</code> |EXAMPLE2=
|r2= [[Array]]


|x3= Return dead and alive entities but logic:<code>_notlogic = [[entities]] [<nowiki/>[], ["Logic"], [[true]]];</code> |EXAMPLE3=
|x1= <sqf>_allCars = entities "Car";</sqf>


|x4= Return all alive [[west]] soldiers on foot:<code>_footsoldiers = [[entities]] [<nowiki/>["SoldierWB"], [], [[false]], [[true]]];</code> |EXAMPLE4=
|x2= Return all alive entities on the map:
____________________________________________________________________________________________
<sqf>_allAlive = entities [[], [], true, true];</sqf>


| [[nearEntities]], [[allUnits]], [[vehicles]], [[agents]], [[allMissionObjects]] |SEEALSO=
|x3= Return dead and alive entities but logic:
}}
<sqf>_notLogic = entities [[], ["Logic"], true];</sqf>


<h3 style='display:none'>Notes</h3>
|x4= Return all alive [[west]] soldiers on foot:
<dl class='command_description'>
<sqf>_footSoldiers = entities [["SoldierWB"], [], false, true];</sqf>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|seealso= [[nearEntities]] [[allGroups]] [[allUnits]] [[units]] [[vehicles]] [[agents]] [[playableUnits]] [[switchableUnits]] [[allPlayers]] [[allDead]] [[allDeadMen]] [[allUnitsUAV]] [[allCurators]] [[allObjects]] [[allMissionObjects]] [[allSimpleObjects]] [[allMines]]
</dl>
}}
 
<h3 style='display:none'>Bottom Section</h3>
 
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}

Latest revision as of 18:11, 11 April 2024

Hover & click on the images for description

Description

Description:
Returns a list of all alive and dead entities of the given type or deriving from the given type. Units in vehicles are ignored with the primary syntax.
Optimisation tip: Keep number of types in both includeTypes and excludeTypes arrays to a minimum by possibly using parent/base classes.
If you have to use several types, arrange them in order so that the more common types go at the beginning of the array.
Groups:
Object Detection

Syntax

Syntax:
entities type
Parameters:
type: String - if an empty string "" is provided, all entities are returned
Return Value:
Array

Alternative Syntax

Syntax:
entities [typesInclude, typesExclude, includeCrews, excludeDead]
Parameters:
typesInclude: Array - in format [type1, type2, ...typeN], where type is a String. Empty array [] means include every entity. Method used for filtering - isKindOf
typesExclude: Array - in format [type1, type2, ...typeN], where type is a String. Empty array [] means exclude no entity. Method used for filtering - isKindOf
includeCrews: Boolean - (Optional, default false) include crews currently in vehicles
excludeDead: Boolean - (Optional, default false) exclude dead entities
Return Value:
Array

Examples

Example 1:
_allCars = entities "Car";
Example 2:
Return all alive entities on the map:
_allAlive = entities [[], [], true, true];
Example 3:
Return dead and alive entities but logic:
_notLogic = entities [[], ["Logic"], true];
Example 4:
Return all alive west soldiers on foot:
_footSoldiers = entities [["SoldierWB"], [], false, true];

Additional Information

See also:
nearEntities allGroups allUnits units vehicles agents playableUnits switchableUnits allPlayers allDead allDeadMen allUnitsUAV allCurators allObjects allMissionObjects allSimpleObjects allMines

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note