Other great resources: Official JS API docs, Scripting Forum
objFromId()
- Aubergine
- Shadow Wolf TJC
Owned by Aubergine
Retrieve a game object based on it's ID...
Syntax
var gameObj = objFromId(idObj); // use with care!!
Parameters
Parameter | Type | Mandatory | Description | Game version |
---|---|---|---|---|
idObj | Object | 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: 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
Value | Type | Description | Game version |
---|---|---|---|
<gameObj> | Game object | A Droid object, Structure object or Feature object that has the specified object id. | 3.1 Beta 2 |
null | Null | The object was not found. | 3.1 Beta 2 |
<error> | Error | Due 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:
- On Warzone 3.2+ use getObject()
- On Warzone 3.2 early developer releaes, use hackGetObj()
Earlier versions:
- On Warzone 3.1 Beta 1, use droidFromId()
Contents
Jump to:
See also
Related articles:
- enumFeature() – get a list of feature objects
- enumDroid() – get a list of droid objects
- enumStruct() – get a list of structure objects