Manual:DIL Manual/Built-In Procedures

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:40, 14 November 2026 by Agent-mud (talk | contribs) (manual index generated from the checked keyword pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A procedure does something and returns no value, so it is a statement of its own: exec("say Hello", self);. cast_spell() can be called either way: see Built-In Functions.

Each line gives the call with its arguments and what it does. Click a name for the full page. Statements such as if, while and goto are in DIL Constructs.

Strings, lists and bits

Procedure What it does
addstring(sl : stringlist, s : string) Adds a string to the end of a stringlist.
substring(sl : stringlist, s : string) Removes a string from a stringlist.
insert(list : stringlist or intlist, i : integer, value : string or integer) Puts a new entry into a stringlist or an intlist at a given position.
remove(list : stringlist or intlist, i : integer) Takes the entry at a given position out of a stringlist or an intlist.
set(i : integer, bits : integer) Turns bits on in an integer variable or field.
unset(i : integer, bits : integer) Turns bits off in an integer variable or field.

Text to players

Procedure What it does
act(text : string, show : integer, char : unitptr, medium : unitptr or string, victim : unitptr or string, to : integer) Shows a message to the characters around someone, worded for each of them.
sendtext(text : string, u : unitptr) Sends a text to one character's screen, exactly as it is.
pagestring(s : string, u : unitptr) Sends a long text to a player, to be shown a page at a time.
beginedit(pc : unitptr) Lets a player type several lines of text, which the program then gets.
killedit(u : unitptr) Takes a player out of the text editor.

Messages between programs

Messages are covered in Messages.

Procedure What it does
send(msg : string) Sends a message to the DIL programs around the unit.
sendto(msg : string, u : unitptr) Sends a message to the DIL programs on one unit.
sendtoall(m : string, s : string) Sends a message to every copy of a unit in the game.
sendtoalldil(m : string, s : string) Sends a message to every running copy of a DIL template.
send_done(cmd : string, activator : unitptr, medium : unitptr, target : unitptr, power : integer, arg : string, other : unitptr, auto : integer) Tells the programs around that a command has been carried out.
dispatch(s : string) Sends a line to programs outside the game, such as the Discord bot.

Waiting and events

How a program waits for events and handles them.

Procedure What it does
wait(events : integer, condition) Stops the program until an event of the given kinds comes, for which a condition holds.
block Stops the event that woke the program from going any further.
priority Keeps the unit's later programs from getting any event until nopriority.
nopriority Ends the priority set by this program.
clear(i : integer) Removes an interrupt set up with interrupt().
secure(u : unitptr, label) Keeps a unit in a variable across waits, and names where to go when it leaves.
unsecure(u : unitptr) Ends the secure on a unit.
quit Ends the program for good.

DIL programs

Procedure What it does
dilcopy(s : string, u : unitptr) Starts a copy of a DIL template on a unit.

Moving and changing units

Procedure What it does
exec(cmd : string, ch : unitptr) Makes a character carry out a command, as if they had typed it.
link(u : unitptr, into : unitptr) Moves a unit into another unit, with no checks and no messages.
destroy(u : unitptr) Removes a unit from the game.
store(u : unitptr, filename : string, container : integer) Saves a unit, or what is inside it, to a file.
follow(ch : unitptr, leader : unitptr) Makes one character follow another, or stop following.
setbright(u : unitptr, light : integer) Sets how much light a unit gives.
set_weight(u : unitptr, weight : integer) Sets a unit's total weight.
set_weight_base(u : unitptr, weight : integer) Sets a unit's own weight.
addextra(list : extraptr, names : stringlist, text : string)
addextra(list : extraptr, names : stringlist, text : string, vals : intlist)
Adds an extra description to a unit's extras, quests or info.
subextra(list : extraptr, name : string) Removes an extra description by name.
addaff(u : unitptr, id : integer, duration : integer, beat : integer, data0 : integer, data1 : integer, data2 : integer, tif_first : integer, tif_tick : integer, tif_last : integer, apf : integer) Adds an affect to a unit.
subaff(u : unitptr, id : integer) Removes an affect from a unit.
addequip(u : unitptr, pos : integer) Puts an object a character carries on, at a given position.
unequip(u : unitptr) Takes off an object a character is wearing.
setroomexit(room : unitptr, dir : integer, toroom : unitptr) Points a room's exit in one direction at another room, making the exit if the room has none that way.
zonereset(z : zoneptr) Resets a zone now.

Characters and combat

Procedure What it does
set_fighting(u : unitptr, t : unitptr) Starts a fight between two characters.
stop_fighting(u : unitptr, t : unitptr) Ends a character's fight with one opponent, or with all.
change_speed(u : unitptr, delay : integer) Delays a fighting character's next attacks.
position_update(u : unitptr) Sets a character's position from its hit points, and kills it at -11 or below.
experience(amount : integer, pc : unitptr) Gives a player experience points, or takes them away.
logcrime(criminal : unitptr, victim : unitptr, crime : integer) Reports a crime to the justice system: who did it, to whom, and what.

Players and the server

All of these except gamestate() and log() work only in a zone with access level 0.

Procedure What it does
acc_modify(pc : unitptr, amount : integer) Pays money into a player's account or takes it out.
gamestate(pc : unitptr, gs : integer) Takes a player out of the game to the menu, back into the game, or out altogether.
set_password(pc : unitptr, pwd : string) Sets a player's password.
delete_player(pname : string) Deletes a player character for good.
reset_level(pc : unitptr) Sets a mortal player's level back to 1.
reset_vlevel(pc : unitptr) Sets a mortal player's virtual level back to 1.
reset_race(pc : unitptr) Rolls a player's body again from the race's values: weight, height, lifespan and age.
log(s : string) Writes a line to the server log.
reboot(code : integer) Shuts the game server down.

See also