GetFirstObjectInArea

From NWN Lexicon



Contents

[edit] GetFirstObjectInArea(object)

Determines the first object in an area.

object GetFirstObjectInArea(
    object oArea = OBJECT_INVALID
);

[edit] Parameters

oArea

The area that contains the objects. (Default: OBJECT_INVALID)


[edit] Description

Returns the first object in oArea and OBJECT_INVALID if no objects exists or on any error.

If no valid area is specified, it will use the caller's area.



[edit] Remarks

Useful for making sure all things of a cirtain tag, or type, in an area are destroyed and may be easier then using GetObjectByTag().

Do not do it too often in larger, or more populated areas.

There is no way to loop areas in a module, which is a shame (unless a system is devised). Therefore, it is hard to loop all objects in a module (although this is almost never ever ever required).


[edit] Known Bugs

Sound objects and creatures possessed by a DM are skipped. Sound objects can instead be fetched by using GetObjectByTag, GetNearestObjectByTag or similar.


[edit] Version

1.62

[edit] Example

// Any objects in the area tagged "DESTROY" are destroyed.
// Uses OBJECT_SELF as the area, but this can be subsituted for
// many things.
 
void main()
{
    // Loop all objects in us, an area
    object oArea = OBJECT_SELF;
    object oObject = GetFirstObjectInArea(oArea);
    while(GetIsObjectValid(oObject))
    {
         // Destroy any objects tagged "DESTROY"
         if(GetTag(oObject) == "DESTROY")
         {
             DestroyObject(oObject);
         }
         oObject = GetNextObjectInArea(oArea);
    }
}

[edit] See Also

functions: 

GetNextObjectInArea



 author: Tom Cassiotis, editor: Jasperre, additional contributor(s): Enigmatic, Jazael, Charles Feduke, Jasperre
 

Personal tools
Categories