Difference between revisions of "Manual:DIL Manual"
(manual index generated from the checked keyword pages) |
|||
| Line 1: | Line 1: | ||
| + | '''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 (<code>.zon</code>) between <code>dilbegin</code> and <code>dilend</code>, 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 [[Manual:DIL Manual/self|<code>self</code>]]. 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 == | |
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | Put on an NPC, this waits until a player has walked into the room, makes the NPC say hello, and waits again. [[Manual:DIL Manual/wait()|<code>wait()</code>]] sleeps until an event of the given kind (here [[Manual:DIL Manual/SFB DONE|<code>SFB_DONE</code>]], something has happened) makes the condition true; [[Manual:DIL Manual/activator|<code>activator</code>]] is the character who caused it; [[Manual:DIL Manual/exec()|<code>exec()</code>]] makes the NPC type a command. | ||
| − | + | == Chapters == | |
| − | + | Read in this order to learn the language: | |
| − | + | # [[Manual:DIL Manual/Making a Program|Making a Program]]: the parts of a program and how it runs. | |
| + | # [[Manual:DIL Manual/Data Types|Data Types]]: integer, string, stringlist, intlist, unitptr, extraptr, zoneptr, cmdptr. | ||
| + | # [[Manual:DIL Manual/Assignment|Assignment]]: giving variables and fields values. | ||
| + | # [[Manual:DIL Manual/Expressions|Expressions]]: values and how they are combined. | ||
| + | # [[Manual:DIL Manual/Operators|Operators]]: arithmetic, comparison, <code>and</code>, <code>or</code>, <code>not</code>, <code>in</code>. | ||
| + | # [[Manual:DIL Manual/DIL Constructs|DIL Constructs]]: <code>if</code>, <code>while</code>, <code>foreach</code>, <code>goto</code> and the other statements. | ||
| + | # [[Manual:DIL Manual/Messages|Messages]]: events, and how programs wait for them and talk to each other. | ||
| + | # [[Manual:DIL Manual/Functions|Functions]]: writing your own functions and procedures, and calling them from other zones. | ||
| + | # [[Manual:DIL Manual/Built-In Functions|Built-In Functions]]: the functions DIL provides, by purpose. | ||
| + | # [[Manual:DIL Manual/Built-In Procedures|Built-In Procedures]]: the procedures DIL provides, by purpose. | ||
| + | # [[Manual:DIL Manual/Built-In Variables|Built-In Variables]]: <code>self</code>, <code>activator</code> and the others the server sets. | ||
| + | # [[Manual:DIL Manual/Fields|Fields]]: the values in units, extras, zones and commands, by unit type. | ||
| + | # [[Manual:DIL Manual/Ending Notes|Ending Notes]]. | ||
| + | # [[Manual:DIL Examples|DIL Examples]]: answers to the questions new DIL writers ask most. | ||
| − | + | == Every keyword == | |
| − | + | The [[Manual:DIL Manual (Full Listing)|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. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | [[Manual: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
[[Category:Manual Title Pages]] | [[Category:Manual Title Pages]] | ||
Revision as of 23:39, 14 November 2026
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:
- Making a Program: the parts of a program and how it runs.
- Data Types: integer, string, stringlist, intlist, unitptr, extraptr, zoneptr, cmdptr.
- Assignment: giving variables and fields values.
- Expressions: values and how they are combined.
- Operators: arithmetic, comparison,
and,or,not,in. - DIL Constructs:
if,while,foreach,gotoand the other statements. - Messages: events, and how programs wait for them and talk to each other.
- Functions: writing your own functions and procedures, and calling them from other zones.
- Built-In Functions: the functions DIL provides, by purpose.
- Built-In Procedures: the procedures DIL provides, by purpose.
- Built-In Variables:
self,activatorand the others the server sets. - Fields: the values in units, extras, zones and commands, by unit type.
- Ending Notes.
- 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.