openclonk/docs/sdk/script/fn/Collect.xml

45 lines
1.9 KiB
XML

<?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>Collect</title>
<category>Objects</category>
<subcat>Contents</subcat>
<version>1.0 OC</version>
<syntax>
<rtype>bool</rtype>
<params>
<param>
<type>object</type>
<name>item</name>
<desc>Object to be collected.</desc>
</param>
<param>
<type>bool</type>
<name>ignore_ocf</name>
<desc>Ignores the fact that a container must have OCF_Collection for it to collect an object.</desc>
</param>
</params>
</syntax>
<desc>Collects an object. This function performs the same events as they occur if the object is collected in the game through the Collection area (there will be a RejectCollect call, flag collection checks, hit calls, etc.) The only difference is that there will be no comparison of collection position and the collected item is not checked for the OCF_Carryable flag.<br/>Using this function you can for example collect objects directly from a container. If the function fails (e.g. through a RejectCollect or a full target container) the function returns <code>false</code>, otherwise <code>true</code>.</desc>
<examples>
<example>
<code>protected func ContainedUse(object clonk)
{
var obj = <funclink>Contents</funclink>();
if (obj)
if (!clonk-&gt;Collect(obj))
clonk-&gt;<funclink>Message</funclink>(&quot;Collect not possible.&quot;,clonk);
<funclink>return</funclink> true;
}
</code>
<text>With contained use the first inventory object is passed to the selected clonk.</text>
</example>
</examples>
<related><funclink>Enter</funclink></related>
</func>
<author>Sven2</author><date>2002-05</date>
</funcs>