Difference between revisions of "Manual:DIL Manual"

From DikuMUD Wiki
Jump to navigation Jump to search
(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.
  
−
'''You can view a full listing of the DIL manual at [[Manual:DIL_Manual_(Full_Listing)]] or browse by topic using the links below.'''
+
== 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.
  
−
<h3>AGENT.md</h3>
+
== Chapters ==
−
Get the latest [https://github.com/Seifert69/DikuMUD3/blob/master/vme/doc/dil/AGENTS.md AGENTS.md on Github] to make your LLM create better code.
+
Read in this order to learn the language:
−
This [[Manual:DIL_Manual/AGENT|local copy]] is mostly for search engines.
+
# [[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.
  
−
<h3>Index</h3>
+
== 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.
−
<b>PLEASE NOTE that the documentation in vme/doc/dil/*.wiki is much more comprehensive than the wiki. We're currently blocked from importing pages (315 of them)</b>
 
−
 
 
−
[[Manual:DIL_Manual/Making a Program|Making a Program]]
 
−
 
 
−
[[Manual:DIL_Manual/Data Types|Data Types]]
 
−
  [[Manual:DIL_Manual/string|string]]
 
−
  [[Manual:DIL_Manual/stringlist|stringlist]]
 
−
  [[Manual:DIL_Manual/integer|integer]]
 
−
  [[Manual:DIL_Manual/integerlist|integerlist]]
 
−
  [[Manual:DIL_Manual/extraptr|extraptr]]
 
−
  [[Manual:DIL_Manual/cmdptr|cmdptr]]
 
−
  [[Manual:DIL_Manual/unitptr|unitptr]]
 
−
  [[Manual:DIL_Manual/zoneptr|zoneptr]]
 
−
 
 
−
[[Manual:DIL_Manual/Messages|Messages]]
 
−
  [[Manual:DIL_Manual/SFB_CMD|SFB_CMD]]
 
−
  [[Manual:DIL_Manual/SFB_DONE|SFB_DONE]]
 
−
  [[Manual:DIL_Manual/SFB_TICK|SFB_TICK]]
 
−
  [[Manual:DIL_Manual/SFB_COM|SFB_COM]]
 
−
  [[Manual:DIL_Manual/SFB_DEAD|SFB_DEAD]]
 
−
  [[Manual:DIL_Manual/SFB_MSG|SFB_MSG]]
 
−
  [[Manual:DIL_Manual/SFB_PRE|SFB_PRE]]
 
−
 
 
−
[[Manual:DIL_Manual/Built-In Variables|Built-In Variables]]
 
−
  [[Manual:DIL_Manual/cmdstr|cmdstr]]
 
−
  [[Manual:DIL_Manual/excmdstr|excmdstr]]
 
−
  [[Manual:DIL_Manual/excmdstr_case|excmdstr_case]]
 
−
  [[Manual:DIL_Manual/self|self]]
 
−
  [[Manual:DIL_Manual/activator|activator]]
 
−
  [[Manual:DIL_Manual/target|target]]
 
−
  [[Manual:DIL_Manual/medium|medium]]
 
−
  [[Manual:DIL_Manual/power|power]]
 
−
  [[Manual:DIL_Manual/argument|argument]]
 
−
  [[Manual:DIL_Manual/heartbeat|heartbeat]]
 
−
  [[Manual:DIL_Manual/null|null]]
 
−
  [[Manual:DIL_Manual/weather|weather]]
 
−
  [[Manual:DIL_Manual/realtime|realtime]]
 
−
  [[Manual:DIL_Manual/mud(day,month,..)|mud(day,month,..)]]
 
−
 
 
−
[[Manual:DIL_Manual/DIL Constructs|DIL Constructs]]
 
−
  [[Manual:DIL_Manual/if()|if()]]
 
−
  [[Manual:DIL_Manual/goto|goto]]
 
−
  [[Manual:DIL_Manual/while()|while()]]
 
−
  [[Manual:DIL_Manual/break|break]]
 
−
  [[Manual:DIL_Manual/continue|continue]]
 
−
  [[Manual:DIL_Manual/on ... goto ...|on ... goto ...]]
 
−
  [[Manual:DIL_Manual/foreach()|foreach()]]
 
−
 
 
−
[[Manual:DIL_Manual/Assignment|Assignment]]
 
−
 
 
−
[[Manual:DIL_Manual/Expressions|Expressions]]
 
−
 
 
−
[[Manual:DIL_Manual/Operators|Operators]]
 
−
  [[Manual:DIL_Manual/in|in]]
 
−
  [[Manual:DIL_Manual/string in string|string in string]]
 
−
  [[Manual:DIL_Manual/string in stringlist|string in stringlist]]
 
−
  [[Manual:DIL_Manual/string in extraptr|string in extraptr]]
 
−
 
 
−
[[Manual:DIL_Manual/Functions|Functions]]
 
−
  [[Manual:DIL_Manual/quit|quit]]
 
−
  [[Manual:DIL_Manual/return|return]]
 
−
  [[Manual:DIL_Manual/return()|return()]]
 
−
 
 
−
[[Manual:DIL_Manual/Fields|Fields]]
 
−
  [[Manual:DIL_Manual/extraptr|extraptr]]
 
−
  [[Manual:DIL_Manual/unitptr|unitptr]]
 
−
  [[Manual:DIL_Manual/UNIT_ST_OBJ|UNIT_ST_OBJ]]
 
−
  [[Manual:DIL_Manual/UNIT_ST_ROOM|UNIT_ST_ROOM]]
 
−
  [[Manual:DIL_Manual/UNIT_ST_PC and UNIT_ST_NPC|UNIT_ST_PC and UNIT_ST_NPC]]
 
−
  [[Manual:DIL_Manual/UNIT_ST_NPC|UNIT_ST_NPC]]
 
−
  [[Manual:DIL_Manual/UNIT_ST_PC|UNIT_ST_PC]]
 
−
 
 
−
[[Manual:DIL_Manual/Built-In Functions|Built-In Functions]]
 
−
  [[Manual:DIL_Manual/asctime()|asctime()]]
 
−
  [[Manual:DIL_Manual/strcmp()|strcmp()]]
 
−
  [[Manual:DIL_Manual/strncmp()|strncmp()]]
 
−
  [[Manual:DIL_Manual/textformat()|textformat()]]
 
−
  [[Manual:DIL_Manual/spellindex()|spellindex()]]
 
−
  [[Manual:DIL_Manual/spellinfo()|spellinfo()]]
 
−
  [[Manual:DIL_Manual/beginedit()|beginedit()]]
 
−
  [[Manual:DIL_Manual/cancarry()|cancarry()]]
 
−
  [[Manual:DIL_Manual/fits()|fits()]]
 
−
  [[Manual:DIL_Manual/replace()|replace()]]
 
−
  [[Manual:DIL_Manual/restore()|restore()]]
 
−
  [[Manual:DIL_Manual/meleeattack()|meleeattack()]]
 
−
  [[Manual:DIL_Manual/meleedamage()|meleedamage()]]
 
−
  [[Manual:DIL_Manual/mid()|mid()]]
 
−
  [[Manual:DIL_Manual/moneystring()|moneystring()]]
 
−
  [[Manual:DIL_Manual/equipment()|equipment()]]
 
−
  [[Manual:DIL_Manual/tolower()|tolower()]]
 
−
  [[Manual:DIL_Manual/toupper()|toupper()]]
 
−
  [[Manual:DIL_Manual/visible()|visible()]]
 
−
  [[Manual:DIL_Manual/opponent()|opponent()]]
 
−
  [[Manual:DIL_Manual/purse()|purse()]]
 
−
  [[Manual:DIL_Manual/atoi()|atoi()]]
 
−
  [[Manual:DIL_Manual/check_password()|check_password()]]
 
−
  [[Manual:DIL_Manual/command()|command()]]
 
−
  [[Manual:DIL_Manual/delstr()|delstr()]]
 
−
  [[Manual:DIL_Manual/delunit()|delunit()]]
 
−
  [[Manual:DIL_Manual/dildestroy()|dildestroy()]]
 
−
  [[Manual:DIL_Manual/dilfind()|dilfind()]]
 
−
  [[Manual:DIL_Manual/itoa()|itoa()]]
 
−
  [[Manual:DIL_Manual/isaff()|isaff()]]
 
−
  [[Manual:DIL_Manual/islight()|islight()]]
 
−
  [[Manual:DIL_Manual/isplayer()|isplayer()]]
 
−
  [[Manual:DIL_Manual/isset()|isset()]]
 
−
  [[Manual:DIL_Manual/paycheck()|paycheck()]]
 
−
  [[Manual:DIL_Manual/filesize()|filesize()]]
 
−
  [[Manual:DIL_Manual/findunit()|findunit()]]
 
−
  [[Manual:DIL_Manual/findrndunit()|findrndunit()]]
 
−
  [[Manual:DIL_Manual/findroom()|findroom()]]
 
−
  [[Manual:DIL_Manual/findsymbolic()|findsymbolic()]]
 
−
  [[Manual:DIL_Manual/getword()|getword()]]
 
−
  [[Manual:DIL_Manual/getwords()|getwords()]]
 
−
  [[Manual:DIL_Manual/ghead()|ghead()]]
 
−
  [[Manual:DIL_Manual/split()|split()]]
 
−
  [[Manual:DIL_Manual/left()|left()]]
 
−
  [[Manual:DIL_Manual/length()|length()]]
 
−
  [[Manual:DIL_Manual/load()|load()]]
 
−
  [[Manual:DIL_Manual/loadstr()|loadstr()]]
 
−
  [[Manual:DIL_Manual/openroll()|openroll()]]
 
−
  [[Manual:DIL_Manual/pathto()|pathto()]]
 
−
  [[Manual:DIL_Manual/pagestring()|pagestring()]]
 
−
  [[Manual:DIL_Manual/right()|right()]]
 
−
  [[Manual:DIL_Manual/rnd()|rnd()]]
 
−
  [[Manual:DIL_Manual/Built-In Procedures|Built-In Procedures]]
 
−
  [[Manual:DIL_Manual/follow()|follow()]]
 
−
  [[Manual:DIL_Manual/flog()|flog()]]
 
−
  [[Manual:DIL_Manual/logcrime()|logcrime()]]
 
−
  [[Manual:DIL_Manual/acc_modify()|acc_modify()]]
 
−
  [[Manual:DIL_Manual/strdir()|strdir()]]
 
−
  [[Manual:DIL_Manual/set_password()|set_password()]]
 
−
  [[Manual:DIL_Manual/store()|store()]]
 
−
  [[Manual:DIL_Manual/position_update()|position_update()]]
 
−
  [[Manual:DIL_Manual/send_done()|send_done()]]
 
−
  [[Manual:DIL_Manual/send_pre()|send_pre()]]
 
−
  [[Manual:DIL_Manual/set()|set()]]
 
−
  [[Manual:DIL_Manual/unset()|unset()]]
 
−
  [[Manual:DIL_Manual/addcolor()|addcolor()]]
 
−
  [[Manual:DIL_Manual/delcolor()|delcolor()]]
 
−
  [[Manual:DIL_Manual/getcolor()|getcolor()]]
 
−
  [[Manual:DIL_Manual/changecolor()|changecolor()]]
 
−
  [[Manual:DIL_Manual/gamestate()|gamestate()]]
 
−
  [[Manual:DIL_Manual/addextra()|addextra()]]
 
−
  [[Manual:DIL_Manual/addstring()|addstring()]]
 
−
  [[Manual:DIL_Manual/subextra()|subextra()]]
 
−
  [[Manual:DIL_Manual/substring()|substring()]]
 
−
  [[Manual:DIL_Manual/stop_fighting()|stop_fighting()]]
 
−
  [[Manual:DIL_Manual/subaff()|subaff()]]
 
−
  [[Manual:DIL_Manual/addaff()|addaff()]]
 
−
  [[Manual:DIL_Manual/destroy()|destroy()]]
 
−
  [[Manual:DIL_Manual/walkto()|walkto()]]
 
−
  [[Manual:DIL_Manual/link()|link()]]
 
−
  [[Manual:DIL_Manual/weapon_name()|weapon_name()]]
 
−
  [[Manual:DIL_Manual/weapon_info()|weapon_info()]]
 
−
  [[Manual:DIL_Manual/skill_name()|skill_name()]]
 
−
  [[Manual:DIL_Manual/reboot|reboot]]
 
−
  [[Manual:DIL_Manual/killedit|killedit]]
 
−
  [[Manual:DIL_Manual/experience()|experience()]]
 
−
  [[Manual:DIL_Manual/act()|act()]]
 
−
  [[Manual:DIL_Manual/exec()|exec()]]
 
−
  [[Manual:DIL_Manual/wait()|wait()]]
 
−
  [[Manual:DIL_Manual/savestr()|savestr()]]
 
−
  [[Manual:DIL_Manual/remove()|remove()]]
 
−
  [[Manual:DIL_Manual/reset_level()|reset_level()]]
 
−
  [[Manual:DIL_Manual/reset_vlevel()|reset_vlevel()]]
 
−
  [[Manual:DIL_Manual/reset_race()|reset_race()]]
 
−
  [[Manual:DIL_Manual/secure()|secure()]]
 
−
  [[Manual:DIL_Manual/unitdir()|unitdir()]]
 
−
  [[Manual:DIL_Manual/unsecure()|unsecure()]]
 
−
  [[Manual:DIL_Manual/block|block]]
 
−
  [[Manual:DIL_Manual/priority|priority]]
 
−
  [[Manual:DIL_Manual/nopriority|nopriority]]
 
−
  [[Manual:DIL_Manual/addequip()|addequip()]]
 
−
  [[Manual:DIL_Manual/unequip()|unequip()]]
 
−
  [[Manual:DIL_Manual/delete_player()|delete_player()]]
 
−
  [[Manual:DIL_Manual/dilcopy()|dilcopy()]]
 
−
  [[Manual:DIL_Manual/sendtext()|sendtext()]]
 
−
  [[Manual:DIL_Manual/change_speed()|change_speed()]]
 
−
  [[Manual:DIL_Manual/transfermoney()|transfermoney()]]
 
−
  [[Manual:DIL_Manual/set_fighting()|set_fighting()]]
 
−
  [[Manual:DIL_Manual/set_weight_base|set_weight_base()]]
 
−
  [[Manual:DIL_Manual/set_weight|set_weight()]]
 
−
  [[Manual:DIL_Manual/setbright()|setbright()]]
 
−
  [[Manual:DIL_Manual/log()|log()]]
 
−
  [[Manual:DIL_Manual/send()|send()]]
 
−
  [[Manual:DIL_Manual/sendto()|sendto()]]
 
−
  [[Manual:DIL_Manual/sendtoall()|sendtoall()]]
 
−
  [[Manual:DIL_Manual/sendtoalldil()|sendtoalldil()]]
 
−
  [[Manual:DIL_Manual/cast_spell()|cast_spell()]]
 
−
  [[Manual:DIL_Manual/attack_spell()|attack_spell()]]
 
−
  [[Manual:DIL_Manual/insert()|insert()]]
 
−
  [[Manual:DIL_Manual/interrupt()|interrupt()]]
 
−
  [[Manual:DIL_Manual/clear()|clear()]]
 
−
  [[Manual:DIL_Manual/on_activation()|on_activation()]]
 
−
  [[Manual:DIL_Manual/shell()|shell()]]
 
−
  [[Manual:DIL_Manual/getaffects()|getaffects()]]
 
−
 
 
−
[[Manual:DIL_Manual/Ending Notes|Ending Notes]]
 
  
 
[[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:

  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.