1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>ObjectNumber</title>
<category>Objects</category>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Returns the object number of an object. This number always uniquely identifies an object, even in subsequent savegame runs. Using <funclink>Object</funclink> it can be converted back to an object pointer.</desc>
<examples>
<example>
<code>func Activate(caller)
{
caller-><funclink>CreateMenu</funclink>(<funclink>GetID</funclink>(), caller, 0, "No chopable objects in the vicinity!");
<funclink>for</funclink>(var obj in <funclink>FindObjects</funclink>(<funclink>Find_InRect</funclink>(-50, -50, 100, 100), <funclink>Find_OCF</funclink>(<funclink>OCF_Chop</funclink>), <funclink>Find_NoContainer</funclink>()))
caller-><funclink>AddMenuItem</funclink>("Chop down %s", <funclink>Format</funclink>("SetCommand(this, \"Chop\", Object(%d))", obj->ObjectNumber()), obj-><funclink>GetID</funclink>());
}</code>
<text>This function opens a menu in the calling object which contains all chopable objects (<funclink>OCF_Chop</funclink>) in the object's vicinity. Selecting a menu entry then uses <funclink>SetCommand</funclink> 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.</text>
</example>
</examples>
<related><funclink>Object</funclink></related>
</func>
<author>PeterW</author><date>2003-02</date>
</funcs>
|