Manual:DIL Manual

From DikuMUD Wiki
Revision as of 23:39, 14 November 2026 by Agent-mud (talk | contribs) (manual index generated from the checked keyword pages)
Jump to navigation Jump to search

DIL (DikuMUD Interpreted Language) is the scripting language of DikuMUD3. Almost everything in the game that reacts or changes is a DIL program: monsters that talk, fight or wander, doors that lock themselves, quests, spells and skills, and many of the commands players type.

A program is written in a zone file (.zon) between dilbegin and dilend, and compiled with the rest of the zone by vmc, the zone compiler. The game server runs it on a unit: a room, an object, an NPC or a player, which the program calls self. Most programs wait for an event (a command typed nearby, a message from another program, time passing) and then act on it.

A small example

dilbegin greeter();
code
{
   :start:
   wait(SFB_DONE, command(CMD_AUTO_ENTER) and (activator.type == UNIT_ST_PC));
   exec("say Welcome, " + activator.name + "!", self);
   goto start;
}
dilend

Put on an NPC, this waits until a player has walked into the room, makes the NPC say hello, and waits again. wait() sleeps until an event of the given kind (here SFB_DONE, something has happened) makes the condition true; activator is the character who caused it; exec() makes the NPC type a command.

Chapters

Read in this order to learn the language:

  1. Making a Program: the parts of a program and how it runs.
  2. Data Types: integer, string, stringlist, intlist, unitptr, extraptr, zoneptr, cmdptr.
  3. Assignment: giving variables and fields values.
  4. Expressions: values and how they are combined.
  5. Operators: arithmetic, comparison, and, or, not, in.
  6. DIL Constructs: if, while, foreach, goto and the other statements.
  7. Messages: events, and how programs wait for them and talk to each other.
  8. Functions: writing your own functions and procedures, and calling them from other zones.
  9. Built-In Functions: the functions DIL provides, by purpose.
  10. Built-In Procedures: the procedures DIL provides, by purpose.
  11. Built-In Variables: self, activator and the others the server sets.
  12. Fields: the values in units, extras, zones and commands, by unit type.
  13. Ending Notes.
  14. DIL Examples: answers to the questions new DIL writers ask most.

Every keyword

The Full Listing has every keyword of the language on one page, by kind, with a line on what each does. Each keyword's own page gives its arguments, what it returns, notes from the server's code and an example.