Versions Compared

Key

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

Overview

Excerpt

Returns a list of all

...

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. This enumLabels() function gets a list of all the label names defined in labels.ini (the bits in square brackets).

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.

Availability

...

currently defined labels...

 

Syntax

Code Block
theme

...

RDark
languagejavascript
linenumberstrue
// 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

...

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

...

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

Code Block
theme

...

RDark
languagejavascript
titleIterate

...

all labels, getting the objects associated with them...
linenumberstrue

...

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

...


...

	}

...

See also

...

} );
Code Block
themeRDark
languagejavascript
titleIterate AREA labels and create listeners for them...
linenumberstrue
enumLabels(AREA).forEach( function createListener(labelName) {
	this["eventArea"+labelName] = function(droid) {
		console("A droid entered AREA: "+labelName);
	}
} );
Div
classbox
Availability
Status
colourGreen
title3.1 b3+

Requires:

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

Jump to:

Table of Contents
maxLevel5

Include Page
.jslinks-labels
.jslinks-labels