count: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 52: Line 52:




(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:
'''count''' units [[group]] [[player]]<br>
 
or <br>
'''count''' units [[group]] [[player]]
'''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>
or
{[[alive]] _x} count units [[group]] [[player]] <br>
 
or <br>
'''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
{[[alive]] _x} count units groupname

Revision as of 23:13, 2 May 2006


condition count array


Operand types:

condition: String

array: Array

Type of returned value:

Number

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