ObjectNumber

Category: Objects
Since engine version: 4.9.1.0 GWE

Description

Returns the object number of an object. This number always uniquely identifies an object, even in subsequent savegame runs. Using Object it can be converted back to an object pointer.

Syntax

int ObjectNumber (object pObj);

Parameter

pObj:
Object of which you want to determine the object number.

Example

func Activate(pCaller)
{
  CreateMenu(GetID(), pCaller, pCaller, 0, "Kein geeignetes Objekte in Reichweite!");
  var obj;
  while(obj = FindObject(0, -50, -50, 100, 100, OCF_Chop(), 0, 0, NoContainer(), obj))
    AddMenuItem("%s fällen", Format("SetCommand(this(), \"Chop\", Object(%d))", ObjectNumber(obj)), GetID(obj), pCaller);
}
This function opens a menu in the calling object (pCaller) which contains all chopable objects (OCF_Chop()) in the object's vicinity. Selecting a menu entry then uses SetCommand to set the command "Chop" in the object. Since this requires storage of the object pointer, the pointer is first converted into the object number.
See also: Object
PeterW, Februar 2003