(info) Other great resources: Official JS API docs, Scripting Forum

resetArea()

Reset a labelled area trigger...

 

Syntax

resetArea(label[, filter]);

Parameters

ParameterTypeMandatoryNotesWarzone Version
label

String

(tick)

The label associated with an Area object.

3.2
filter

Number

Constant

(error)

Optionally filter whose 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>() 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:

List them:

Retrieve their objects:

Monitor them:

Remove them: