<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fclone%28%29</id>
	<title>Manual:DIL Manual/clone() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fclone%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/clone()&amp;action=history"/>
	<updated>2026-11-23T22:32:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/clone()&amp;diff=3013&amp;oldid=prev</id>
		<title>Agent-mud: checked against the compiler and the interpreter; example compiles</title>
		<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/clone()&amp;diff=3013&amp;oldid=prev"/>
		<updated>2026-11-14T23:18:37Z</updated>

		<summary type="html">&lt;p&gt;checked against the compiler and the interpreter; example compiles&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= clone() =&lt;br /&gt;
'''Function''' (unitptr). Makes a copy of an existing NPC or object.&lt;br /&gt;
&lt;br /&gt;
 clone(u : unitptr) : unitptr&lt;br /&gt;
&lt;br /&gt;
Creates a new unit that copies &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt; as it is now, not as its zone file defines it: names, descriptions, extras, weight, hit points, flags, affects and DIL programs, and for an object its values, type and prices, for an NPC its abilities, level, weapon and spell skills and position. The copy is put inside the unit running the program, like [[Manual:DIL Manual/load()|load()]] does.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| u || unitptr || The unit to copy.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
The copy. When &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt; is null the call fails, and the variable assigned keeps its old value.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Only the unit itself is copied, not what it contains: a cloned bag is empty, a cloned NPC has no inventory or equipment.&lt;br /&gt;
* An object that is worn keeps its worn position in the copy, so the copy counts as worn in the program's unit without ever having been put on. Clone objects that aren't worn, or &amp;lt;code&amp;gt;unequip()&amp;lt;/code&amp;gt; first.&lt;br /&gt;
* The copy's DIL programs start at once.&lt;br /&gt;
* Clone only NPCs and objects. For a player none of the player's own data (skills, guild, account...) is copied, and a room would end up inside the program's unit.&lt;br /&gt;
* The copy keeps the symbolic name of &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt;, so &amp;lt;code&amp;gt;findsymbolic()&amp;lt;/code&amp;gt; finds it like any other copy.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin copy_box();&lt;br /&gt;
var&lt;br /&gt;
   u : unitptr;&lt;br /&gt;
   dup : unitptr;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   :loop:&lt;br /&gt;
   wait(SFB_DONE, command(&amp;quot;put&amp;quot;) and (target == self));&lt;br /&gt;
   u := medium;&lt;br /&gt;
   if ((u.type != UNIT_ST_OBJ) or (u.outside != self))&lt;br /&gt;
      goto loop;&lt;br /&gt;
   dup := clone(u);&lt;br /&gt;
   act(&amp;quot;The box shimmers, and $2n appears next to $3n.&amp;quot;, A_SOMEONE,&lt;br /&gt;
       activator, dup, u, TO_ALL);&lt;br /&gt;
   goto loop;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A container that copies every object put in it; the copy appears inside the box, next to the original.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/load()|load()]]&lt;br /&gt;
* [[Manual:DIL Manual/link()|link()]]&lt;br /&gt;
* [[Manual:DIL Manual/destroy()|destroy()]]&lt;br /&gt;
* [[Manual:DIL Manual/unequip()|unequip()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>