GetNearestObjectToLocation(int, location, int)

Returns the nearest object, which is of a specified type, to a given location.

object GetNearestObjectToLocation(
    int nObjectType,
    location lLocation,
    int nNth = 1
);

Parameters

nObjectType

OBJECT_TYPE_*

lLocation

nNth

(Default: 1)


Description

Get the nNth object nearest to lLocation that is of the specified type.
Return value on error: OBJECT_INVALID

The function selects the Nth (default is 1, i.e. nearest) nearest object that is of a certain type to the given location. By default ‘type’ is set to OBJECT_TYPE_ALL, therefore the function will return the Nth nearest valid object to a given location by simply passing a location value to the function, unless you specify a ‘type’ in the form OBJECT_TYPE_* (see end of description for a complete list of valid object types).

List of available object types constants:
OBJECT_TYPE_ALL (default)
OBJECT_TYPE_AREA_OF_EFFECT
OBJECT_TYPE_CREATURE
OBJECT_TYPE_DOOR
OBJECT_TYPE_ITEM
OBJECT_TYPE_ITEM
OBJECT_TYPE_PLACEABLE
OBJECT_TYPE_STORE
OBJECT_TYPE_TRIGGER
OBJECT_TYPE_WAYPOINT



Version

1.22

See Also

functions: GetNearestObject | GetObjectByTag
categories: Get Data from Object Functions
constants: OBJECT_TYPE_* Constants


 author: Jason Simpson
 Send comments on this topic.