Manual:DIL Manual/dilcopy()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:22, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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