count: Difference between revisions
No edit summary |
No edit summary |
||
Line 53: | Line 53: | ||
(2) Take care when using count to determine how many units are left alive in a group:<br> | (2) Take care when using count to determine how many units are left alive in a group:<br> | ||
'''count''' | '''count''' units [[group]] [[player]]<br> | ||
or <br> | or <br> | ||
'''count''' | '''count''' units groupname<br> | ||
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:<br> | 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:<br> | ||
{[[alive]] _x} count | {[[alive]] _x} count units [[group]] [[player]] <br> | ||
or <br> | or <br> | ||
{[[alive]] _x} count | {[[alive]] _x} count units groupname |
Revision as of 22:26, 2 May 2006
condition count array
Operand types:
condition: String
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:
count units group player
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