Versions Compared

Key

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

Reset a labelled area trigger...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
resetArea(label[, filter]);

Parameters

ParameterTypeMandatoryNotesWarzone Version
label

String

(tick)

The label associated with an Area object.

3.2
filter

Number

Constant

(error)

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:

  • Player ID – specific player
  • ALL_PLAYERS – any player

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

ValueTypeNotesWarzone Version
undefinedUndefinedThe function does not return anything if sucessful.3.2
<error>ErrorAn 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
themeRDark
languagejavascript
linenumberstrue
// 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
classbox
Availability
Status
colourYellow
title3.2+

Requires:

  • Warzone 3.2 or above
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Include Page
.jslinks-labels
.jslinks-labels