ResortObject

Category: Objects / Position
Since engine version: 4.9.1.0 GWE

Description

Resorts a single object in the internal object array. The sorting order is determined through a sorting function which should define the object position relative to other objects in the object array. If the first object is to be sorted before the second, the function should return a value less than zero. Otherwise, the function should return a value greater than or equal to zero.

Syntax

bool ResortObject (string szResortFunc, object pResortObj);

Parameters

szResortFunc:
Name of the function to be called for sorting order.
pResortObj:
[opt] Object to be resorted. Can be 0 in local calls.

Remark

Internal sorting is not done immediately but at the end of the frame in which the function was called.

Example

protected func Collection2() { return(ResortObject("ResortProc"); };
protected func ResortProc(pObj1, pObj2) { return(GetMass(pObj1)-GetMass(pObj2));
Object script: if collected, the object resorts itself in the object array according to its mass (lighter objects in front).
See also: Resort, ResortObjects, SetObjectOrder
Sven2, Juni 2003