getObject()

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

getObject()

Three ways to retrieve a specific object...

 

Syntax

This function has 3 syntax options...
// Syntax #1: Retrieve object by label: var obj = getObject(labelName);   // Syntax #2: Retrieve object by location (map tile): var obj = getObject(x, y);   // Syntax #3: Retrieve object by player, id and type: var obj = getObject(type, player, id);

Parameters

Syntax

Parameter

Type

Mandatory

Description

Game version

Syntax

Parameter

Type

Mandatory

Description

Game version

#1

labelName

String

Retrieve the object associated with the label name.

See Labels for more information.

3.2

#2

x, y

Number

Specify the x,y co-ordinates of a map tile to return the Structure object or Feature object on that tile.

You cannot retrieve droid objects using this syntax, as there can be more than one droid on a tile. Instead, use enumArea() or enumRange().

3.2

#3

type

Constant

The type of object to retrieve:

3.2

#3

player

Number

The player to which the object belongs.

When retrieving feature objects, specify player as -1.

3.2

#3

id

Number

The object ID.

3.2

Return value

Value

Type

Description

Game version

Value

Type

Description

Game version

<object>

Game object

Location object

The object that was retrieved.

You can determine what sort of object it is by inspecting its .type property.

3.2

undefined

Undefined

The label was not found (applies to Syntax #1).

3.2

null

Null

No object was found.

3.2

<error>

Error

Invalid parameters specified.

3.2

Notes

In earlier versions of Warzone, where getObject() is not available, there are some alternatives which you can use:

Syntax 1: Label

Syntax 2: Location

Syntax 3: Object IDs

Syntax 1: Label

Syntax 2: Location

Syntax 3: Object IDs

3.2 early masters:

3.1 branch:

3.2 early masters:

3.1 branch – filter results from:

3.2 early masters:

3.1 Beta 2 → 3.1.0:

3.1 Beta 1:

Example

Syntax 1: Label
var obj = getObject("foo"); // retrieve object labelled "foo"   if (obj) { // do stuff with the obj }
Syntax 2: Location
var obj = getObject(7, 3); // retrieve structure/feature on tile 7,3   if (obj) { // do stuff with the obj }
Syntax 3: Object IDs
var obj = getObject(DROID, me, 63); // retrieve my droid #63   if (obj) { // do stuff with the obj }