Other great resources: Official JS API docs, Scripting Forum
groupSize()
- Aubergine
Owned by Aubergine
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 }
In Warzone 3.2, a new groupSizes[] global array allows iteration though groups and sizes.
Availability 3.1 B1+
Requires:
- Warzone 3.1 Beta 1 and above.
- Buggy in 3.1.0 (see notes section)
Contents
Jump to:
Scripting: Groups
Related Objects:
Create them:
- newGroup() – create a new group
- WZ 3.2+ – add to a group that doesn't exist yet
- labels.ini – group map-placed objects
Add things to them:
- groupAdd() – add any Game object
- groupAddDroid() – add a Droid object
- groupAddArea() – add Game objects within an area of the map
Remove things from them:
- Put them in some other group
Count objects in them:
- groupSize() – get number of items in a group
- groupSizes[] – iterate group sizes
List them:
- groupSizes[] – elements are group ids
- getObject() – retrieve a group by its label
Retrieve their objects:
- enumGroup() – retrieve objects in a group
Monitor them:
- eventGroupLoss() – triggers when an object is removed from a group
Remove them:
- not currently possible