GetObjectByTag

The   NWScript command finds an object with the the indicated tag (specified as a string). It returns OBJECT_INVALID if no object was found. A common use for this command is to find an object with a unique tag (i.e. the object with the indicated tag), but it also handles multiple objects with the same tag.

This command cannot be use to find the module object; use  instead. (All other types of objects can be found.)

Definition
The game maintains an ordering of objects with the same tag. The  parameter indicates which object in this order is being requested. Since the order should be considered arbitrary, the  parameter is usually used as part of a loop. If the  parameter runs past the end of the order, then no object is found (OBJECT_INVALID is returned).