GetObjectByTag(string, int)
Retrieves an object based on the tag given to it.
object GetObjectByTag( string sTag, int nNth = 0 );
Parameters
sTag
The tag of the object to search for.
nNth
The Nth object with this tag may be requested. (Default: 0)
Description
Returns the nNth object of the specified tag or OBJECT_INVALID if the object cannot be found.
sString cannot be "", this will return OBJECT_INVALID.
Remarks
The nNth parameter has been determined to return the nNth object with the specified sTag starting at position 0. Outside of the current area, the scan will begin starting with the last (most recent) area added to the module following this hierarchy:
OBJECT_TYPE_STORE (128)
OBJECT_TYPE_PLACEABLE (64)
OBJECT_TYPE_WAYPOINT (32)
OBJECT_TYPE_AREA_OF_EFFECT (16) (spell effects, like web)
OBJECT_TYPE_DOOR (8)
OBJECT_TYPE_TRIGGER (4)
OBJECT_TYPE_ITEM (2)
OBJECT_TYPE_CREATURE (1)
GetObjectByTag can also be used to get areas, but not the module (use GetModule() instead). It is unknown what will be returned if an area has the same tag as a non-object area.
Known Bugs
The feature of "" returning player characters (IE: Those objects without a tag) has been fixed or changed in 1.64, and now properly returns OBJECT_INVALID.
Version
1.61
Example
// Demonstrates how to retrieve an object with the GetObjectByTag() funciton and apply a spell effect to it. void main() { //makes the world appear dark to NPC Bob ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDarkness(), GetObjectByTag("NPC_BOB")); }
See Also
functions: | ActionJumpToObject | GetNearestObjectByTag | GetNearestObjectToLocation | GetTag |
categories: | Get Data from Object Functions |
author: Sarev0k, editors: Jasperre, Mistress, additional contributors: David Scott, Glenn Berden, Lilac Soul, Jeff Robertson, Kolyana