enumRange()

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

enumRange()

List all objects within a specified range of a position on the map...

 

Syntax

var results = enumRange(x, y, range[, filter[, seen]]);

Parameters

Parameter

Type

Mandatory

Notes

Game Version

Parameter

Type

Mandatory

Notes

Game Version

x

Number

The x co-ordinate of the position

3.2

y

Number

The y co-ordinate of the position

3.2

range

Number

The range, in map tiles, from the position to search for objects

3.2

filter

Number

Constant

Optionally filter the list to objects owned by a specific player ID or a category of players:

Default: ALL_PLAYERS

3.2

seen

Boolean

Should the list be filtered to objects you can see?

  • true – yes, filter to visible objects

  • false – no, return all objects

Default: true

3.2

Return values

Value

Type

Notes

Game Version

Value

Type

Notes

Game Version

<results>

Array of
Game objects

A list of objects matching the specified criteria. Use their .type property to determine what sort of object they are.

3.2

[]

Empty Array

If no objects are found, an empty array is returned.

3.2

<error>

Error

Invalid parameters or map loctation.

3.2

Notes

The returned list will include Feature objects unless you filter to ENEMIES or ALLIES.

Example

// get a list of all enemies within 10 tiles of (20,30) var results = enumRange(20, 30, 10, ENEMIES, false);   results.forEach( function(gameObject) { switch (gameObject.type) { case DROID: { // do stuff with droid break; } case STRUCTURE: { // do stuff with structure break; } } } );