Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Current »

Returns a list of all currently defined labels...

 

Syntax

// Warzone 3.1 Beta 3 and above
var list = enumLabels();
 
// Warzone 3.2 and above
var list = enumLabels([filter]);

Parameters

ParameterTypeMandatoryNotesGame version
filterConstant(error)

Optionally filter the list of labels by their associated object .type:

When specified, only label names associated with the specified object type will be returned.

Default: No filter

3.2

Return value

ValueTypeDescriptionGame version
<list>Array of String

A list of label names currently registered with the JS API.

Use label() (WZ 3.1) or getObject() (WZ 3.2+) to get the object associated with a label.

3.1 Beta 3
[]Empty ArrayIf there are no labels yet, or no labels matching the filter, an empty array is returned.3.1 Beta 3

Example

Iterate all labels, getting the objects associated with them...
enumLabels().forEach( function getObjectFor(labelName) {
	var obj = label(labelName); // retrieve object
	if (obj) {
		// do stuff with object
	} else {
		// there are no objects associated with this label
	}
} );
Iterate AREA labels and create listeners for them...
enumLabels(AREA).forEach( function createListener(labelName) {
	this["eventArea"+labelName] = function(droid) {
		console("A droid entered AREA: "+labelName);
	}
} );
Availability 3.1 B3+

Requires:

  • Warzone 3.1 Beta 3 and above.
  • Optional 'filter' parameter added in Warzone 3.2
Contents

Jump to:

Scripting: Labels

Related Objects:

 Create them:

List them:

Retrieve their objects:

Monitor them:

Remove them:

 

  • No labels