Other great resources: Official JS API docs, Scripting Forum
resetArea()
- Aubergine
Syntax
resetArea(label[, filter]);
Parameters
Parameter | Type | Mandatory | Notes | Warzone Version |
---|---|---|---|---|
label | String | The label associated with an Area object. | 3.2 | |
filter | Number Constant | Optionally filter whose droids will trigger the event:
If you want to filter to enemies/allies, use ALL_PLAYERS and inside the event handler use allianceExistsBetween() to determine if the droid is an enemy or not. Default: ALL_PLAYERS | 3.2 |
Return value
Value | Type | Notes | Warzone Version |
---|---|---|---|
undefined | Undefined | The function does not return anything if sucessful. | 3.2 |
<error> | Error | An error occurred, most likely invalid parameters. | 3.2 |
Notes
Any labelled Area object will trigger an eventArea<Label>() when a droid enters it.
By default, any droid will trigger the event – you can use resetArea() to specify which players' droids should trigger it if desired.
The event will only trigger once and then disable itself, meaning that even if more droids enter the area the event won't trigger any more. You can use resetArea() to re-enable the event so that it will trigger again the next time a droid enters it.
There's three ways in which Area objects can be created:
- Use a map editor, like FlaME, to define and label an area
- Define the area manually in the labels.ini file associated with the map – remember to specify it's label!
- Create a custom area object in a script and use addLabel() to label it (see example below)
It should be noted that within scripts everything uses the tile co-ordinate system, whereas everything in a map or labels.ini uses the world co-ordinate system (1 tile = 128 pixels).
Example
// label an area (can also be done via labels.ini)... var myArea = {x:10, y:11, x2:30, y2:51, type:AREA}; // tile co-odinates addLabel(myArea, "TriggerZone"); // by default the area will trigger if any player enters, // but let's filter it to player 0 (human game host) resetArea("TriggerZone", 0); // create event listener... function eventAreaTriggerZone(droid) { // do stuff // and if we want, reset the event so it triggers next time... resetArea("TriggerZone", 0); }
Availability 3.2+
Requires:
- Warzone 3.2 or above
Contents
Jump to:
Scripting: Labels
Related Objects:
Create them:
- addLabel() – label an object
List them:
- getLabel() – get first label associated with a specific object
- enumLabels() – get a list of all labels
Retrieve their objects:
- getObject() – get object associated with a label
- label() – use this instead on WZ 3.1
Monitor them:
- eventArea<Label>() – triggered when a droid enters a labelled Area object
- resetArea() – reset or filter an area trigger
Remove them:
- removeLabel() – remove a label