count: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 10: | Line 10: | ||
'''Operand types:''' | '''Operand types:''' | ||
'''condition:''' [[ | '''condition:''' [[Code]] | ||
'''array:''' [[Array]] | '''array:''' [[Array]] |
Revision as of 00:46, 6 July 2006
condition count array
Operand types:
condition: Code
array: Array
Type of returned value:
Description:
Counts elements in array for which given condition is true.
It is calculated as follows:
Set count to 0.
For each element of array assign element as _x and evaluate condition expression.
If true increase count.
Example:
{_x > 2} count [0, 1, 1, 2, 3, 3] ...... Result is 2
In general:
{condition} count array
returns the number of elements in the array for which the condition is true. If {condition} is not specified then the number of elements in the array is returned.
Example:
count [0, 1, 1, 2, 3, 3] ...... Result is 6
Comments:
(1) Use this to calculate how many "M16" mags a soldier has left.
("_x == {M16}" count magazines soldier1)
(2) Take care when using count to determine how many units are left alive in a group:
or
count units groupname
Will return the number of units the leader of the group thinks are alive.
If some units have been killed out of sight of other members of the group then it may take sometime for this to be the actual numbers in the group.
To determine exactly how many units are really alive in a group use:
{alive _x} count units group player
or
{alive _x} count units groupname