GetObjectType() NWScript command serves to identify what kind of object its parameter is, returning am OBJECT_TYPE_* constant. If its parameter is not a valid object, it returns 0 (not an OBJECT_TYPE_* constant).
int GetObjectType (object oTarget
- The object whose type will be returned.
The return value is usually an OBJECT_TYPE_* constant. The exceptions are invalid objects, area objects, and the module object; zero is returned in each of these cases. Also of note is that OBJECT_TYPE_INVALID is returned for sound objects. (This is the only time OBJECT_TYPE_INVALID is returned, so one might consider "invalid" to mean "sound" in this particular case.)
Known issues Edit
There are two types of objects (areas and modules) that this command cannot identify. As workarounds,
GetModule() can be used.
Specifically, the expression
GetArea(oObject) == oObject
is true precisely when oObject is an area, and
GetModule() == oObject
is true precisely when oObject is the module.