Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Excerpt

Returns a list of all currently defined labels defined in the current map...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
// Warzone 3.1 Beta 3 and above
var returnValue list = enumLabels();
 
// Warzone 3.2 and above
var list = enumLabels([filter]);

Parameters

The function has no 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
<array><list>Array ot of String

An array of strings, each string being the name of a label defined in the current map's labels.ini file.

(info) Use label(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 name.

3.21 Beta 3
[]Empty ArrayIf there are no labels defined in the current map (or it has no labels.ini file) yet, or no labels matching the filter, an empty array will be is returned.3.2

Notes

Map makers can use labels as a way of passing information about their map to scripts. The labels are defined in a "labels.ini" file (example) either manually or by using Flame, the Warzone map editor. The enumLabels() function gets a list of all the label names defined in labels.ini (the bits in square brackets).

Once you have a list of labels, use label() to get the objects associated with them.

Labels are generally only useful in campaigns and challenges, where there are specific scripts running that know what to expect in the maps being used.

For general maps, used in skirmish and multiplayer games, I've posted some ideas about a naming convention for labels that could possibly make labels more widely applicable.

1 Beta 3

Example

Code Block
themeRDark
languagejavascript
titleMake an object that lists Iterate all labels and , getting the objects associated with them...
linenumberstrue
enumLabels().forEach( function getObjectFor(labelName) {
	var labelsobj = enumLabellabel(labelName); // getretrieve listobject
of all labels
var labelObjects = [];
 
labels.forEach( function(label) { // get object	if (obj) {
		// do stuff with object
	} else {
		// there are no objects associated with eachthis label
in turn
	labelObjects.push[label];
	labelObjects[label] = label(label);
} );
 
// you now have an object that lists all labels, and their objects...
labelObjects	}
} );
Code Block
themeRDark
languagejavascript
titleIterate AREA labels and create listeners for them...
linenumberstrue
enumLabels(AREA).forEach( function createListener(labellabelName) {
	labelObjects[label]; // the object associated with the labelthis["eventArea"+labelName] = function(droid) {
		console("A droid entered AREA: "+labelName);
	}
} );
Div
classbox
Availability
Status
colour
Yellow
Green
title3.
2
1 b3+

Requires:

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

See also

Related articles:

  • addLabel() – add a label to an object
  • label() – get object data for a specific label name
  • eventArea<LABEL>() – event that triggers when droids enter a labelled Area object
  • Map – summary of JS API features associated with maps
  • Mapping forum – forum on main warzone website where mapppers hang out
    Div
    classbox
    Contents

    Jump to:

    Table of Contents
    maxLevel5

    Div
    classbox

    Include Page
    .jslinks-labels
    .jslinks-labels