Other great resources: Official JS API docs, Scripting Forum
groupSize()
Find out how many droids there are in a specific group...
Syntax
var size = groupSize(groupID);Parameters
Parameter | Type | Mandatory | Description | Game version |
|---|---|---|---|---|
groupID | Number | The ID of the droid group. This ID is generated when you create a new group using newGroup(). | 3.1 Beta 1 |
Return value
Value | Type | Description | Game verison |
|---|---|---|---|
<size> | Number | The number of droids in the group. | 3.1 Beta 1 Buggy in 3.1.0 |
<error> | Error | The group did not exist. | 3.1 Beta 1 |
Notes
In Warzone 3.1.0 release, there is a bug that can cause groupSize(group) to return a value of enumGroup(group).length+1.
Read important notes about changes to groups in Warzone 3.2.
Example
Output number of droids in a group
var myGroup = newGroup();
function eventDroidBuilt(droid, structure) {
groupAddDroid(myGroup,droid);
// output size of group to console
console(groupSize(myGroup));
// using groupSize() is much faster than doing this:
console(enumGroup(myGroup).length); // same thing, but much slower
}