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

objFromId()

Retrieve a game object based on it's ID...

 

Syntax

var gameObj = objFromId(idObj); // use with care!!

Parameters

ParameterTypeMandatoryDescriptionGame version
idObjObject(tick)

An object that has an .id property who's value is the ID of the object you wish to retrieve.

For example, if you want to retrieve object #63, you'd pass in: {id:63}

You could also pass in a cached Game object to get a fresh copy of that game object (all game objects have an .id property).

3.1 Beta 2

Return value

ValueTypeDescriptionGame version
<gameObj>Game objectA Droid object, Structure object or Feature object that has the specified object id.3.1 Beta 2
nullNullThe object was not found.3.1 Beta 2
<error>ErrorDue to bugs, if object is not found an error is usually thrown.3.1 Beta 2

Example

Always wrap calls to objFromId() in try...catch blocks...
var lookingFor = {id:63};
var found;
 
try {
	found = objFromId(lookingFor);
} catch(e) {
	found = null;
}
 
if (found) {
	// do stuff with 'found' game object
}
This function is deprecated as of Warzone 3.2.
Availability 3.1 B2→3.1.0

Requires:

  • Warzone 3.1 Beta 2 → 3.1.0

Replaced by:

Earlier versions:

Contents

Jump to:

See also

Related articles: