Difference between revisions of "Manual:DIL Manual/Built-In Functions"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(manual index generated from the checked keyword pages)
 
Line 1: Line 1:
−
<span id="built_func"></span>
+
A function computes a value and returns it, so it is used inside an expression: <code>n := rnd(1, 6);</code>. Functions that change things (such as [[Manual:DIL Manual/load()|load()]] or [[Manual:DIL Manual/transfermoney()|transfermoney()]]) return a value as well, and the value can be ignored. For writing your own functions, see [[Manual:DIL Manual/Functions|Functions]].
  
−
<h3>Built-In Functions:</h3>
+
Each line gives the call with its arguments, the type of the value it returns, and what it does. Click a name for the full page: arguments, return values on failure, notes and an example that compiles. The [[Manual:DIL Manual (Full Listing)|Full Listing]] has every keyword on one page.
  
−
    The following are definitions and documentation for the
+
__TOC__
−
  built-in functions in DIL. The definitions are not
 
−
  definitions 'as such', but serve to distinguish arguments
 
−
  in the documentation below.
 
  
 +
== Strings ==
 +
Text in and out of strings, and numbers as text.
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/atoi()|atoi]](s : string)</code> || integer || The number written at the start of a string.
 +
|-
 +
| <code>[[Manual:DIL Manual/itoa()|itoa]](i : integer)</code> || string || An integer written as text.
 +
|-
 +
| <code>[[Manual:DIL Manual/length()|length]](s : string)</code><br><code>length(sl : stringlist)</code><br><code>length(il : intlist)</code> || integer || The length of a string, or the number of entries in a list.
 +
|-
 +
| <code>[[Manual:DIL Manual/left()|left]](s : string, n : integer)</code> || string || Returns the first characters of a string.
 +
|-
 +
| <code>[[Manual:DIL Manual/right()|right]](s : string, n : integer)</code> || string || Returns the last characters of a string.
 +
|-
 +
| <code>[[Manual:DIL Manual/mid()|mid]](s : string, first : integer, last : integer)</code> || string || Returns the characters from one position to another.
 +
|-
 +
| <code>[[Manual:DIL Manual/getword()|getword]](s : string)</code> || string || Takes the first word off a string.
 +
|-
 +
| <code>[[Manual:DIL Manual/getwords()|getwords]](s : string)</code> || stringlist || Splits a string into its words.
 +
|-
 +
| <code>[[Manual:DIL Manual/split()|split]](s : string, sep : string)</code> || stringlist || Cuts a string into pieces at a separator.
 +
|-
 +
| <code>[[Manual:DIL Manual/replace()|replace]](old : string, new : string, s : string)</code> || string || Replaces every occurrence of one text in a string with another.
 +
|-
 +
| <code>[[Manual:DIL Manual/tolower()|tolower]](s : string)</code> || string || Returns a string in lower case.
 +
|-
 +
| <code>[[Manual:DIL Manual/toupper()|toupper]](s : string)</code> || string || Returns a string in upper case.
 +
|-
 +
| <code>[[Manual:DIL Manual/strcmp()|strcmp]](s1 : string, s2 : string)</code> || integer || Compares two strings, minding upper and lower case.
 +
|-
 +
| <code>[[Manual:DIL Manual/strncmp()|strncmp]](s1 : string, s2 : string, n : integer)</code> || integer || Compares the first characters of two strings, minding upper and lower case.
 +
|-
 +
| <code>[[Manual:DIL Manual/textformat()|textformat]](s : string)</code> || string || Turns the escapes <code>\n</code> and <code>\r</code> in a text into real line breaks.
 +
|}
  
−
---~---~---~---~---~---~---~---~---
+
== Numbers and bits ==
−
<span id="built_func"></span>
+
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/rnd()|rnd]](from : integer, to : integer)</code> || integer || A random whole number in a range.
 +
|-
 +
| <code>[[Manual:DIL Manual/openroll()|openroll]](dice : integer, end : integer)</code> || integer || Rolls an open-ended die: high rolls add another roll, low rolls subtract one.
 +
|-
 +
| <code>[[Manual:DIL Manual/isset()|isset]](value : integer, bits : integer)</code> || integer || Tells whether any of some bits are set in an integer.
 +
|}
  
−
<h3>Built-In Functions:</h3>
+
== Finding units ==
 +
Units by name, symbolic name or kind, and the game's global lists.
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/findunit()|findunit]](u : unitptr, s : string, flags : integer, list : unitptr)</code><br><code>findunit(u : unitptr, s : string, flags : integer, list : unitptr, type : integer)</code> || unitptr || Finds a unit by name, the way commands find what a player names.
 +
|-
 +
| <code>[[Manual:DIL Manual/findrndunit()|findrndunit]](u : unitptr, where : integer, types : integer)</code> || unitptr || Picks a random unit of the wanted kinds in one place.
 +
|-
 +
| <code>[[Manual:DIL Manual/findroom()|findroom]](sym : string)</code> || unitptr || Finds a room by its symbolic name.
 +
|-
 +
| <code>[[Manual:DIL Manual/findsymbolic()|findsymbolic]](sym : string)</code><br><code>findsymbolic(sym : string, idx : integer)</code><br><code>findsymbolic(u : unitptr, sym : string, flags : integer)</code> || unitptr || Finds a unit by its symbolic name, the <code>name@zone</code> it was defined with.
 +
|-
 +
| <code>[[Manual:DIL Manual/findzone()|findzone]](zname : string)</code> || zoneptr || Finds a zone by its name.
 +
|-
 +
| <code>[[Manual:DIL Manual/getcmd()|getcmd]](s : string)</code> || cmdptr || Finds a command from its name or an abbreviation.
 +
|-
 +
| <code>[[Manual:DIL Manual/ghead()|ghead]]()</code> || unitptr || The first unit in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/global head()|global_head]]()</code> || unitptr || Another name for <code>ghead()</code>: the first unit in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/npc head()|npc_head]]()</code> || unitptr || The first NPC in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/obj head()|obj_head]]()</code> || unitptr || The first object in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/pc head()|pc_head]]()</code> || unitptr || The first player in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/room head()|room_head]]()</code> || unitptr || The first room in the game's global unit list.
 +
|-
 +
| <code>[[Manual:DIL Manual/zhead()|zhead]]()</code> || zoneptr || The first zone in the game.
 +
|-
 +
| <code>[[Manual:DIL Manual/zone head()|zone_head]]()</code> || zoneptr || Another name for <code>zhead()</code>: the first zone in the game.
 +
|-
 +
| <code>[[Manual:DIL Manual/chead()|chead]]()</code> || cmdptr || The first command in the game's command table.
 +
|-
 +
| <code>[[Manual:DIL Manual/command head()|command_head]]()</code> || cmdptr || Another name for <code>chead()</code>: the first command in the game's command table.
 +
|}
  
−
    The following are definitions and documentation for the
+
== Making and testing units ==
−
  built-in functions in DIL. The definitions are not
+
{| class="wikitable"
−
  definitions 'as such', but serve to distinguish arguments
+
! Function !! Returns !! What it does
−
  in the documentation below.
+
|-
 +
| <code>[[Manual:DIL Manual/load()|load]](sym : string)</code> || unitptr || Makes a new NPC or object from its zone definition.
 +
|-
 +
| <code>[[Manual:DIL Manual/clone()|clone]](u : unitptr)</code> || unitptr || Makes a copy of an existing NPC or object.
 +
|-
 +
| <code>[[Manual:DIL Manual/equipment()|equipment]](ch : unitptr, pos : integer)</code> || unitptr || The object a character wears or wields in a given position.
 +
|-
 +
| <code>[[Manual:DIL Manual/visible()|visible]](ch : unitptr, u : unitptr)</code> || integer || Tells whether a character can see a unit.
 +
|-
 +
| <code>[[Manual:DIL Manual/islight()|islight]](u : unitptr)</code> || integer || Tells whether there is light in a room.
 +
|-
 +
| <code>[[Manual:DIL Manual/fits()|fits]](ch : unitptr, obj : unitptr, pos : integer)</code> || string || Tells whether an object is the right size for a character.
 +
|-
 +
| <code>[[Manual:DIL Manual/can carry()|can_carry]](ch : unitptr, u : unitptr, n : integer)</code> || integer || Tells whether a character can carry more of something, and if not, why.
 +
|-
 +
| <code>[[Manual:DIL Manual/pathto()|pathto]](from : unitptr, to : unitptr)</code> || integer || Gives the first step of the shortest way from one unit's room to another's.
 +
|-
 +
| <code>[[Manual:DIL Manual/isaff()|isaff]](u : unitptr, id : integer)</code> || integer || Tells whether a unit carries an affect with a given id.
 +
|-
 +
| <code>[[Manual:DIL Manual/getaffects()|getaffects]](u : unitptr)</code> || stringlist || Lists the affects on a unit, one string of numbers each.
 +
|}
  
 +
== Characters and combat ==
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/meleeattack()|meleeattack]](att : unitptr, def : unitptr, bonus : integer, wtype : integer, primary : integer)</code> || integer || Makes a character attack another once in melee, starting a fight.
 +
|-
 +
| <code>[[Manual:DIL Manual/meleedamage()|meleedamage]](att : unitptr, def : unitptr, bonus : integer, wtype : integer)</code> || integer || Makes a character strike another once, without first putting it into combat.
 +
|-
 +
| <code>[[Manual:DIL Manual/opponent()|opponent]](ch : unitptr, vict : unitptr)</code> || integer || Tells whether two characters are fighting each other.
 +
|-
 +
| <code>[[Manual:DIL Manual/getopponent()|getopponent]](ch : unitptr, i : integer)</code> || unitptr || Gets one of a character's opponents by its place in the list.
 +
|-
 +
| <code>[[Manual:DIL Manual/getfollower()|getfollower]](ch : unitptr, i : integer)</code> || unitptr || Gets one of a character's followers by its place in the list.
 +
|-
 +
| <code>[[Manual:DIL Manual/getinteger()|getinteger]](what : integer, u : unitptr, i : integer)</code> || integer || Gets one of several numbers that the server computes, chosen by an index.
 +
|}
  
−
---~---~---~---~---~---~---~---~---
+
== Spells, skills and weapons ==
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/attack spell()|attack_spell]](spell : integer, caster : unitptr, medium : unitptr, target : unitptr, bonus : integer, effect : string)</code> || integer || Hits a target with an offensive spell and returns the damage.
 +
|-
 +
| <code>[[Manual:DIL Manual/cast spell()|cast_spell]](spell : integer, caster : unitptr, medium : unitptr, tgt : unitptr, effect : string)</code><br><code>cast_spell(spell : integer, caster : unitptr, medium : unitptr, tgt : unitptr)</code> || integer (or none, as a procedure) || Casts a spell without mana or the caster's own casting.
 +
|-
 +
| <code>[[Manual:DIL Manual/spellindex()|spellindex]](s : string)</code> || integer || Finds a spell's number from its name or an abbreviation of it.
 +
|-
 +
| <code>[[Manual:DIL Manual/spellinfo()|spellinfo]](i : integer, realm : integer, sphere : integer, mana : integer, offensive : integer, resist : integer, media : integer, targets : integer)</code> || string || Returns a spell's name and puts its properties in seven integer variables.
 +
|-
 +
| <code>[[Manual:DIL Manual/skill name()|skill_name]](i : integer)</code> || string || Gives the name of a skill from its number.
 +
|-
 +
| <code>[[Manual:DIL Manual/weapon name()|weapon_name]](i : integer)</code> || string || Gives the name of a weapon type from its number.
 +
|-
 +
| <code>[[Manual:DIL Manual/weapon info()|weapon_info]](i : integer)</code> || intlist || The figures etc/weapons.def gives a weapon type.
 +
|}
 +
 
 +
== Money ==
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/moneystring()|moneystring]](amt : integer, verbose : integer)</code> || string || Writes an amount of money out in coins.
 +
|-
 +
| <code>[[Manual:DIL Manual/purse()|purse]](u : unitptr, coin : string)</code> || integer || Counts the coins of one kind that a unit carries.
 +
|-
 +
| <code>[[Manual:DIL Manual/transfermoney()|transfermoney]](from : unitptr, to : unitptr, amount : integer)</code> || integer || Moves money from one character to another, or creates or destroys it.
 +
|-
 +
| <code>[[Manual:DIL Manual/paycheck()|paycheck]](pc : unitptr, place : unitptr)</code> || integer || Tells whether a player's account allows them into the zone of a unit.
 +
|}
 +
 
 +
== Players ==
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/isplayer()|isplayer]](pname : string)</code> || integer || Tells whether a player character of that name exists.
 +
|-
 +
| <code>[[Manual:DIL Manual/check password()|check_password]](pc : unitptr, pwd : string)</code> || integer || Tells whether a password is a player's password.
 +
|-
 +
| <code>[[Manual:DIL Manual/getcolor()|getcolor]](key : string)</code> || string || Returns the HTML tag that starts text in a named colour.
 +
|-
 +
| <code>[[Manual:DIL Manual/addcolor()|addcolor]](pc : unitptr, key : string, colour : string)</code> || integer || Gives a player their own colour for a colour name.
 +
|-
 +
| <code>[[Manual:DIL Manual/changecolor()|changecolor]](pc : unitptr, key : string, colour : string)</code> || integer || Changes one of a player's own colours.
 +
|-
 +
| <code>[[Manual:DIL Manual/delcolor()|delcolor]](pc : unitptr, key : string)</code> || integer || Removes one of a player's own colours.
 +
|}
 +
 
 +
== Files ==
 +
Strings and units saved on the server, and the server's logs and programs.
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/loadstr()|loadstr]](filename : string, s : string)</code> || integer || Reads a whole file into a string variable.
 +
|-
 +
| <code>[[Manual:DIL Manual/savestr()|savestr]](filename : string, s : string, mode : string)</code> || integer || Writes a string to a file, to read back later with loadstr().
 +
|-
 +
| <code>[[Manual:DIL Manual/delstr()|delstr]](filename : string)</code> || integer || Deletes a string file.
 +
|-
 +
| <code>[[Manual:DIL Manual/strdir()|strdir]](pattern : string)</code> || stringlist || Lists the string files that DIL has saved, by a pattern.
 +
|-
 +
| <code>[[Manual:DIL Manual/restore()|restore]](filename : string, u : unitptr)</code> || unitptr || Loads units saved with store() back into the game.
 +
|-
 +
| <code>[[Manual:DIL Manual/delunit()|delunit]](filename : string)</code> || integer || Deletes a unit file.
 +
|-
 +
| <code>[[Manual:DIL Manual/unitdir()|unitdir]](pattern : string)</code> || stringlist || Lists the unit files that DIL has stored, by a pattern.
 +
|-
 +
| <code>[[Manual:DIL Manual/flog()|flog]](filename : string, s : string, mode : string)</code> || integer || Writes a string to a file of its own in the server's log directory.
 +
|-
 +
| <code>[[Manual:DIL Manual/shell()|shell]](cmd : string)</code> || integer || Starts a program from the server's <code>allow</code> directory.
 +
|}
 +
 
 +
== Time ==
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/asctime()|asctime]](t : integer)</code> || string || Writes a time in seconds as a date, such as "Mon Nov 18 18:49:08 1996".
 +
|}
 +
 
 +
== Events and messages ==
 +
Which event woke the program, and what other programs say.
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/command()|command]](name : string)</code><br><code>command(no : integer)</code> || integer || Tells whether the event that woke the program is a given command.
 +
|-
 +
| <code>[[Manual:DIL Manual/interrupt()|interrupt]](flags : integer, condition, label)</code> || integer || Sets up a jump to a label when a certain event wakes the program, whatever it is waiting for.
 +
|-
 +
| <code>[[Manual:DIL Manual/on activation()|on_activation]](condition, label)</code><br><code>on_activation(condition, skip)</code> || integer || Sets a check that runs every time the program is woken, by any event, before the event reaches the program's <code>wait()</code> or <code>pause</code>.
 +
|-
 +
| <code>[[Manual:DIL Manual/send pre()|send_pre]](cmd : string, who : unitptr, med : unitptr, tgt : unitptr, pwr : integer, arg : string, other : unitptr)</code> || integer || Asks the programs around a character whether a command may go ahead.
 +
|-
 +
| <code>[[Manual:DIL Manual/sact()|sact]](text : string, show : integer, a1 : unitptr or string, a2 : unitptr or string, a3 : unitptr or string, to : integer)</code> || string || Gives the text an act() would show, instead of sending it.
 +
|}
 +
 
 +
== DIL programs ==
 +
Programs on units, and calling functions by name.
 +
{| class="wikitable"
 +
! Function !! Returns !! What it does
 +
|-
 +
| <code>[[Manual:DIL Manual/dilfind()|dilfind]](tmpl : string, u : unitptr)</code> || integer || Tells whether a unit runs a DIL program from a given template.
 +
|-
 +
| <code>[[Manual:DIL Manual/dildestroy()|dildestroy]](tmpl : string, u : unitptr)</code> || integer || Stops a DIL program on a unit and removes it.
 +
|-
 +
| <code>[[Manual:DIL Manual/dilcall()|dilcall]](tmpl : string)(u : unitptr, i : integer, s : string)</code> || integer || Calls a DIL function whose name is only known when the program runs.
 +
|}
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/Built-In Procedures|Built-In Procedures]]
 +
* [[Manual:DIL Manual/Built-In Variables|Built-In Variables]]
 +
* [[Manual:DIL Manual/Fields|Fields]]
 +
* [[Manual:DIL Manual/Operators|Operators]], for <code>and</code>, <code>or</code>, <code>not</code> and <code>in</code>

Latest revision as of 23:39, 14 November 2026

A function computes a value and returns it, so it is used inside an expression: n := rnd(1, 6);. Functions that change things (such as load() or transfermoney()) return a value as well, and the value can be ignored. For writing your own functions, see Functions.

Each line gives the call with its arguments, the type of the value it returns, and what it does. Click a name for the full page: arguments, return values on failure, notes and an example that compiles. The Full Listing has every keyword on one page.

Strings

Text in and out of strings, and numbers as text.

Function Returns What it does
atoi(s : string) integer The number written at the start of a string.
itoa(i : integer) string An integer written as text.
length(s : string)
length(sl : stringlist)
length(il : intlist)
integer The length of a string, or the number of entries in a list.
left(s : string, n : integer) string Returns the first characters of a string.
right(s : string, n : integer) string Returns the last characters of a string.
mid(s : string, first : integer, last : integer) string Returns the characters from one position to another.
getword(s : string) string Takes the first word off a string.
getwords(s : string) stringlist Splits a string into its words.
split(s : string, sep : string) stringlist Cuts a string into pieces at a separator.
replace(old : string, new : string, s : string) string Replaces every occurrence of one text in a string with another.
tolower(s : string) string Returns a string in lower case.
toupper(s : string) string Returns a string in upper case.
strcmp(s1 : string, s2 : string) integer Compares two strings, minding upper and lower case.
strncmp(s1 : string, s2 : string, n : integer) integer Compares the first characters of two strings, minding upper and lower case.
textformat(s : string) string Turns the escapes \n and \r in a text into real line breaks.

Numbers and bits

Function Returns What it does
rnd(from : integer, to : integer) integer A random whole number in a range.
openroll(dice : integer, end : integer) integer Rolls an open-ended die: high rolls add another roll, low rolls subtract one.
isset(value : integer, bits : integer) integer Tells whether any of some bits are set in an integer.

Finding units

Units by name, symbolic name or kind, and the game's global lists.

Function Returns What it does
findunit(u : unitptr, s : string, flags : integer, list : unitptr)
findunit(u : unitptr, s : string, flags : integer, list : unitptr, type : integer)
unitptr Finds a unit by name, the way commands find what a player names.
findrndunit(u : unitptr, where : integer, types : integer) unitptr Picks a random unit of the wanted kinds in one place.
findroom(sym : string) unitptr Finds a room by its symbolic name.
findsymbolic(sym : string)
findsymbolic(sym : string, idx : integer)
findsymbolic(u : unitptr, sym : string, flags : integer)
unitptr Finds a unit by its symbolic name, the name@zone it was defined with.
findzone(zname : string) zoneptr Finds a zone by its name.
getcmd(s : string) cmdptr Finds a command from its name or an abbreviation.
ghead() unitptr The first unit in the game's global unit list.
global_head() unitptr Another name for ghead(): the first unit in the game's global unit list.
npc_head() unitptr The first NPC in the game's global unit list.
obj_head() unitptr The first object in the game's global unit list.
pc_head() unitptr The first player in the game's global unit list.
room_head() unitptr The first room in the game's global unit list.
zhead() zoneptr The first zone in the game.
zone_head() zoneptr Another name for zhead(): the first zone in the game.
chead() cmdptr The first command in the game's command table.
command_head() cmdptr Another name for chead(): the first command in the game's command table.

Making and testing units

Function Returns What it does
load(sym : string) unitptr Makes a new NPC or object from its zone definition.
clone(u : unitptr) unitptr Makes a copy of an existing NPC or object.
equipment(ch : unitptr, pos : integer) unitptr The object a character wears or wields in a given position.
visible(ch : unitptr, u : unitptr) integer Tells whether a character can see a unit.
islight(u : unitptr) integer Tells whether there is light in a room.
fits(ch : unitptr, obj : unitptr, pos : integer) string Tells whether an object is the right size for a character.
can_carry(ch : unitptr, u : unitptr, n : integer) integer Tells whether a character can carry more of something, and if not, why.
pathto(from : unitptr, to : unitptr) integer Gives the first step of the shortest way from one unit's room to another's.
isaff(u : unitptr, id : integer) integer Tells whether a unit carries an affect with a given id.
getaffects(u : unitptr) stringlist Lists the affects on a unit, one string of numbers each.

Characters and combat

Function Returns What it does
meleeattack(att : unitptr, def : unitptr, bonus : integer, wtype : integer, primary : integer) integer Makes a character attack another once in melee, starting a fight.
meleedamage(att : unitptr, def : unitptr, bonus : integer, wtype : integer) integer Makes a character strike another once, without first putting it into combat.
opponent(ch : unitptr, vict : unitptr) integer Tells whether two characters are fighting each other.
getopponent(ch : unitptr, i : integer) unitptr Gets one of a character's opponents by its place in the list.
getfollower(ch : unitptr, i : integer) unitptr Gets one of a character's followers by its place in the list.
getinteger(what : integer, u : unitptr, i : integer) integer Gets one of several numbers that the server computes, chosen by an index.

Spells, skills and weapons

Function Returns What it does
attack_spell(spell : integer, caster : unitptr, medium : unitptr, target : unitptr, bonus : integer, effect : string) integer Hits a target with an offensive spell and returns the damage.
cast_spell(spell : integer, caster : unitptr, medium : unitptr, tgt : unitptr, effect : string)
cast_spell(spell : integer, caster : unitptr, medium : unitptr, tgt : unitptr)
integer (or none, as a procedure) Casts a spell without mana or the caster's own casting.
spellindex(s : string) integer Finds a spell's number from its name or an abbreviation of it.
spellinfo(i : integer, realm : integer, sphere : integer, mana : integer, offensive : integer, resist : integer, media : integer, targets : integer) string Returns a spell's name and puts its properties in seven integer variables.
skill_name(i : integer) string Gives the name of a skill from its number.
weapon_name(i : integer) string Gives the name of a weapon type from its number.
weapon_info(i : integer) intlist The figures etc/weapons.def gives a weapon type.

Money

Function Returns What it does
moneystring(amt : integer, verbose : integer) string Writes an amount of money out in coins.
purse(u : unitptr, coin : string) integer Counts the coins of one kind that a unit carries.
transfermoney(from : unitptr, to : unitptr, amount : integer) integer Moves money from one character to another, or creates or destroys it.
paycheck(pc : unitptr, place : unitptr) integer Tells whether a player's account allows them into the zone of a unit.

Players

Function Returns What it does
isplayer(pname : string) integer Tells whether a player character of that name exists.
check_password(pc : unitptr, pwd : string) integer Tells whether a password is a player's password.
getcolor(key : string) string Returns the HTML tag that starts text in a named colour.
addcolor(pc : unitptr, key : string, colour : string) integer Gives a player their own colour for a colour name.
changecolor(pc : unitptr, key : string, colour : string) integer Changes one of a player's own colours.
delcolor(pc : unitptr, key : string) integer Removes one of a player's own colours.

Files

Strings and units saved on the server, and the server's logs and programs.

Function Returns What it does
loadstr(filename : string, s : string) integer Reads a whole file into a string variable.
savestr(filename : string, s : string, mode : string) integer Writes a string to a file, to read back later with loadstr().
delstr(filename : string) integer Deletes a string file.
strdir(pattern : string) stringlist Lists the string files that DIL has saved, by a pattern.
restore(filename : string, u : unitptr) unitptr Loads units saved with store() back into the game.
delunit(filename : string) integer Deletes a unit file.
unitdir(pattern : string) stringlist Lists the unit files that DIL has stored, by a pattern.
flog(filename : string, s : string, mode : string) integer Writes a string to a file of its own in the server's log directory.
shell(cmd : string) integer Starts a program from the server's allow directory.

Time

Function Returns What it does
asctime(t : integer) string Writes a time in seconds as a date, such as "Mon Nov 18 18:49:08 1996".

Events and messages

Which event woke the program, and what other programs say.

Function Returns What it does
command(name : string)
command(no : integer)
integer Tells whether the event that woke the program is a given command.
interrupt(flags : integer, condition, label) integer Sets up a jump to a label when a certain event wakes the program, whatever it is waiting for.
on_activation(condition, label)
on_activation(condition, skip)
integer Sets a check that runs every time the program is woken, by any event, before the event reaches the program's wait() or pause.
send_pre(cmd : string, who : unitptr, med : unitptr, tgt : unitptr, pwr : integer, arg : string, other : unitptr) integer Asks the programs around a character whether a command may go ahead.
sact(text : string, show : integer, a1 : unitptr or string, a2 : unitptr or string, a3 : unitptr or string, to : integer) string Gives the text an act() would show, instead of sending it.

DIL programs

Programs on units, and calling functions by name.

Function Returns What it does
dilfind(tmpl : string, u : unitptr) integer Tells whether a unit runs a DIL program from a given template.
dildestroy(tmpl : string, u : unitptr) integer Stops a DIL program on a unit and removes it.
dilcall(tmpl : string)(u : unitptr, i : integer, s : string) integer Calls a DIL function whose name is only known when the program runs.

See also