<?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%2Funique</id>
	<title>Manual:DIL Manual/unique - 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%2Funique"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/unique&amp;action=history"/>
	<updated>2026-11-22T20:51:52Z</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/unique&amp;diff=3126&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/unique&amp;diff=3126&amp;oldid=prev"/>
		<updated>2026-11-14T23:27:15Z</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;= unique =&lt;br /&gt;
'''Keyword.''' Option of &amp;lt;code&amp;gt;dilbegin&amp;lt;/code&amp;gt;: a unit has at most one copy of the program.&lt;br /&gt;
&lt;br /&gt;
 dilbegin unique name(...);&lt;br /&gt;
&lt;br /&gt;
When a &amp;lt;code&amp;gt;unique&amp;lt;/code&amp;gt; template is copied onto a unit that already runs a copy of it, nothing happens: no second copy is made, and the one already there goes on undisturbed. That holds for &amp;lt;code&amp;gt;dilcopy&amp;lt;/code&amp;gt; in a zone file, the &amp;lt;code&amp;gt;dilcopy()&amp;lt;/code&amp;gt; procedure, and the copies the server makes itself (such as the follow and death programs).&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* The test looks for a running program made from the same template on that unit only. Copies on other units don't count.&lt;br /&gt;
* The arguments don't matter: a second &amp;lt;code&amp;gt;dilcopy&amp;lt;/code&amp;gt; with other arguments is ignored too, so the first copy keeps its arguments.&lt;br /&gt;
* Copies loaded with a saved unit are not tested; the test is made when a new copy is added.&lt;br /&gt;
* Without &amp;lt;code&amp;gt;unique&amp;lt;/code&amp;gt;, every &amp;lt;code&amp;gt;dilcopy&amp;lt;/code&amp;gt; adds another copy, and each one reacts to every event.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin unique curse_hunger();&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   heartbeat := PULSE_SEC * 60;&lt;br /&gt;
   :start:&lt;br /&gt;
   pause;&lt;br /&gt;
   if (self.type == UNIT_ST_PC)&lt;br /&gt;
      sendtext(&amp;quot;Your stomach growls.&amp;lt;br/&amp;gt;&amp;quot;, self);&lt;br /&gt;
   goto start;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&lt;br /&gt;
dilbegin feast_curse();&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   :start:&lt;br /&gt;
   wait(SFB_CMD, command(&amp;quot;eat&amp;quot;) and (activator.type == UNIT_ST_PC)&lt;br /&gt;
        and (activator.outside == self.outside));&lt;br /&gt;
   dilcopy(&amp;quot;curse_hunger@ex&amp;quot;, activator);&lt;br /&gt;
   goto start;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;feast_curse&amp;lt;/code&amp;gt;, on a cursed table, puts &amp;lt;code&amp;gt;curse_hunger&amp;lt;/code&amp;gt; on each player who tries to eat in the room. A player who tries twice still gets one growl a minute, not two.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/dilbegin|dilbegin]]&lt;br /&gt;
* [[Manual:DIL Manual/dilcopy()|dilcopy()]]&lt;br /&gt;
* [[Manual:DIL Manual/dilfind()|dilfind()]]&lt;br /&gt;
* [[Manual:DIL Manual/dildestroy()|dildestroy()]]&lt;br /&gt;
* [[Manual:DIL Manual/recall|recall]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>