ObjectNumber

Category: Objects
Since engine version: 1.0 OC

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();

Example

func Activate(caller)
{
  caller->CreateMenu(GetID(), caller, 0, "No chopable objects in the vicinity!");
  for(var obj in FindObjects(Find_InRect(-50, -50, 100, 100), Find_OCF(OCF_Chop), Find_NoContainer()))
    caller->AddMenuItem("Chop down %s", Format("SetCommand(this, \"Chop\", Object(%d))", obj->ObjectNumber()), obj->GetID());
}
This function opens a menu in the calling object 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, 2003-02