Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Reset a labelled area trigger... |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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 the trigger to droids from a specific player ID.Or specify ALL_PLAYERS to trigger when droids from any area enter the areawhose 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>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
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// 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); } |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Include Page | ||||
---|---|---|---|---|
|