LDMud logo: an emblem with three snakes, on the left behind that emblem a cogwheel. In front of both is a sword.


Home of LDMud

View the Project on GitHub ldmud/ldmud


Aside from the functions within an object (so-called lfuns) there are driver-supplied functions, the efuns. Efuns are always available, but can't be called with call_other, because they do not belong to an object.

We'll give here a short overview over commonly used efuns. For the full list, please consult the documentation in the LDMud source.

Object handling

object this_object()
Returns the object pointer for the current object. Use this when you need to give another object a reference of yourself.
object environment(object ob)
An object can have a surrounding object (which can be set with move_object/set_environment). This efun returns the surrounding object of 'ob'.
object* all_inventory(object ob)
Returns an array with all objects that have 'ob' as their surrounding object.
object load_object(string filename)
Compiles the given file into an LPC object and returns a reference to it. The file should have the ending .c and the filename is always interpretated relatively to the mudlib directory (which is a command line argument to the LDMud binary).
object clone_object(string filename)
Create a copy of the object, that is a result of compiling 'filename'.
void destruct(object ob)
Bring the existance of the given object to an end.
mixed call_other(object ob, string fun, args...)
Call the function 'fun' in the object 'ob' with the arguments given after 'fun'.
void call_out(string fun, int delay, args...)
Call the function 'fun' in the current object after 'delay' seconds. Nevertheless this efun will return immediately. The call to 'fun' will happen later independant of the current execution.

Player Handling

object this_interactive()
If this code was executed because of a player entered a command, then this efuns will return a reference to the object representing the player. These player objects are special objects that have a network connection associated with them.
object this_player()
Returns the current command giver. The command giver can be a real player, but can also be a non-player character that issued a command using command. The current command giver will also be preserved when a calling functions via call_out.
object* users()
Returns an array with all player objects (i.e. object that have a live network connection).
void add_action(string fun, string command)
Registers the function 'fun' to be called when the current command giver enters the command 'command'. The function will be called with any text the player entered after the command and must return a non-zero value if it succeeded. (Otherwise the next matching function will be called, until one succeeded.)
void input_to(string fun)
Registers the function 'fun' to be called on the next command entered by the current command giver. This overrides all registered actions, but is just for one command.
int command(string str, object ob)
Let the object 'ob' execute the command 'str'. That means all via add_action to 'ob' registered functions will be searched for matching functions that will be executd.
void write(string msg)
Write the given text to the current command giver.
void say(string msg)
Write the given text to all living objects in the environment of the current command giver.


mixed copy(mixed arg)
Creats a copy of an array or mapping. (For all other types this efun just returns the value.) Please note that if the array or mapping itself contains other reference types as values these are not copied, the values in the original and copy will reference the same data. For deeper copies look at deep_copy.
mixed filter(mixed arg, string fun, object ob, ...)
For each element in arg (may be an array, mapping or string) call ob->fun(element, ...) (for mappings calls ob->fun(key, value, ...)). If the function returns a non-zero value that element or key-value-pair is included in the return array/mapping/string.
mixed map(mixed arg, string fun, object ob, ...)
Similar to filter calls the function for each element, but replaces the element (in mappings the value) with the function's result.
int member(mixed container, mixed element)
Returns the position of element in the container (may be an array, string or mapping). For mappings just 1 for existance and 0 otherwise is returned.
int sizeof(mixed val)
Returns the number of elements in the array or struct, number of characters in the string, or the number of keys in a mapping.
int intp(mixed val)
int floatp(mixed val)
int stringp(mixed val)
int symbolp(mixed val)
int pointerp(mixed val)
int mappingp(mixed val)
int structp(mixed val)
int objectp(mixed val)
int closurep(mixed val)
Returns 1 if the value if an integer, floating point number, string, symbol, array, mapping, struct, object, resp. closure.


string read_file(string file, int start, int number)
Reads 'number' lines from 'file' starting at line 'start'. If 'number' is 0, then everything is read. If you want to read byte-wise try read_bytes.
int write_file(string file, string str)
Appends 'str' to the file 'file'. Returns 1 for success, 0 otherwise.
int save_object(string file)
Writes all saveable variables (i.e. the ones without the nosave modifier) from the current object to the file in an own format suitable to be restored with restore_object.
int restore_object(string file)
Restores all variables from the given file to the current object. Any existing values will be overwritten.