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 | ||||||
---|---|---|---|---|---|---|
| ||||||
// 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.Parameter | Type | Mandatory | Notes | Game version |
---|---|---|---|---|
filter | Constant | 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
Value | Type | Description | Game 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. 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 Array | If 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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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 | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
| ||||
Div | ||||
|
Include Page | ||||
---|---|---|---|---|
|