Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

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

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
var returnValuelist = enumLabels();

Parameters

The function has no parameters.

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) A list of label names currently registered with the JS API.

Use label() to get the object associated with a label name.

3.2
[]Empty ArrayIf there are no labels defined in the current map (or it has no labels.ini file) yet, 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.

Example

Code Block
themeRDark
languagejavascript
titleMake an object that lists Iterate all labels and , getting the objects associated with them...
linenumberstrue
var labels = enumLabel(); // get list of all labels
var labelObjects = [];
 
labels.forEach( function getObjectFor(labellabelName) { // get object associated with each label in turn
	labelObjects.push[label];
	labelObjects[label]
	var obj = label(labellabelName);
} );
  // youretrieve nowobject
have an object that lists all labels, and their objects...
labelObjects.forEach( function(label) {
	labelObjects[label]; // the object	if (obj) {
		// do stuff with object
	} else {
		// there are no objects associated with thethis label
	}
} );
Div
classbox
Availability
Status
colourYellow
title3.2+

Requires:

  • Warzone 3.2 and above.

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