Difference between revisions of "Manual:DIL Manual/dilcopy()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bpdc"></span>
+
= dilcopy() =
−
dilcopy( s : string, u : unitptr )
+
'''Procedure.''' Starts a copy of a DIL template on a unit.
−
    s : Name template to attach to unit.
 
−
    u : Unit to attach a dil program to.
 
−
    result: Attaches a DIL program to a unit 'u', which uses a template
 
−
            named by 's'.
 
  
−
---~---~---~---~---~---~---~---~---
+
  dilcopy(s : string, u : unitptr)
−
<span id="bpdc"></span>
 
−
  dilcopy( s : string, u : unitptr )
 
−
    s : Name template to attach to unit.
 
−
    u : Unit to attach a dil program to.
 
−
    result: Attaches a DIL program to a unit 'u', which uses a template
 
−
            named by 's'.
 
  
−
---~---~---~---~---~---~---~---~---
+
Puts a new program on <code>u</code>, made from the template named in <code>s</code>, with the
 +
arguments written in the string: <code>"name@zone(arg1,arg2,...)"</code>. It is the run-time
 +
version of the <code>dilcopy</code> line in a zone file. The new program starts at the unit's
 +
next tick, within about a second.
 +
 
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| s || string || The template and its arguments: <code>"name@zone"</code> or <code>"name@zone(a,b,...)"</code>.
 +
|-
 +
| u || unitptr || The unit to put the program on.
 +
|}
 +
 
 +
== Notes ==
 +
* Only <code>string</code> and <code>integer</code> arguments can be given; a template with list or unit arguments can't be copied this way.
 +
* The arguments are the text between the brackets, cut at every comma, up to the first <code>)</code>. So a string argument can't hold a comma or a <code>)</code>, and has no quotes around it. Spaces are kept in strings; write no space after the commas. Integers must be plain numbers.
 +
* An empty argument is lost, except the first: <code>"x@zone(a,0,5,)"</code> passes three arguments, not four. Pass a word such as <code>none</code> instead.
 +
* No space between the name and the <code>(</code>.
 +
* A template that isn't found, or gets the wrong number or kind of arguments, isn't started; the zone log of <code>u</code>'s zone says "Template ... not found" or "had mismatching argument count".
 +
* A <code>unique</code> template isn't started on a unit that already runs it.
 +
* The second argument can't be the word <code>null</code> (vmc refuses it). A null unit variable does nothing.
 +
* The string must be shorter than 12288 characters (<code>MAX_STRING_LENGTH</code>): a longer one stops the server.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin give_reward(pc : unitptr);
 +
var
 +
  item : unitptr;
 +
code
 +
{
 +
  item := load("canbelt@hallows23");
 +
  dilcopy("ply_restrict@function(" + pc.name + ",0,25,quest_act@gnome)", item);
 +
  link(item, pc);
 +
  act("You receive $2n.", A_ALWAYS, pc, item, null, TO_CHAR);
 +
  return;
 +
}
 +
dilend
 +
</pre>
 +
Gives a quest reward that only this player may use, as in hallows23.zon.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/dilfind()|dilfind()]]
 +
* [[Manual:DIL Manual/dildestroy()|dildestroy()]]
 +
* [[Manual:DIL Manual/dilcall()|dilcall()]]
 +
* [[Manual:DIL Manual/unique|unique]]
 +
* [[Manual:DIL Manual/load()|load()]]

Latest revision as of 23:22, 14 November 2026

dilcopy()

Procedure. Starts a copy of a DIL template on a unit.

dilcopy(s : string, u : unitptr)

Puts a new program on u, made from the template named in s, with the arguments written in the string: "name@zone(arg1,arg2,...)". It is the run-time version of the dilcopy line in a zone file. The new program starts at the unit's next tick, within about a second.

Parameters

Name Type Meaning
s string The template and its arguments: "name@zone" or "name@zone(a,b,...)".
u unitptr The unit to put the program on.

Notes

  • Only string and integer arguments can be given; a template with list or unit arguments can't be copied this way.
  • The arguments are the text between the brackets, cut at every comma, up to the first ). So a string argument can't hold a comma or a ), and has no quotes around it. Spaces are kept in strings; write no space after the commas. Integers must be plain numbers.
  • An empty argument is lost, except the first: "x@zone(a,0,5,)" passes three arguments, not four. Pass a word such as none instead.
  • No space between the name and the (.
  • A template that isn't found, or gets the wrong number or kind of arguments, isn't started; the zone log of u's zone says "Template ... not found" or "had mismatching argument count".
  • A unique template isn't started on a unit that already runs it.
  • The second argument can't be the word null (vmc refuses it). A null unit variable does nothing.
  • The string must be shorter than 12288 characters (MAX_STRING_LENGTH): a longer one stops the server.

Example

dilbegin give_reward(pc : unitptr);
var
   item : unitptr;
code
{
   item := load("canbelt@hallows23");
   dilcopy("ply_restrict@function(" + pc.name + ",0,25,quest_act@gnome)", item);
   link(item, pc);
   act("You receive $2n.", A_ALWAYS, pc, item, null, TO_CHAR);
   return;
}
dilend

Gives a quest reward that only this player may use, as in hallows23.zon.

See also