Home of LDMud
Functions are code blocks that have a name. Every LPC code that wants to be executed must be somewhere within a function. (There is just one exception: the initialization of global variables.)
A function has a name, a return type, arguments (i.e. values given to the function when called) and its code block:
In this example the first
int denotes the return type.
It's followed by the function name and the arguments in parenthesis.
After that comes the code block in braces.
To call a function within the object just write the name and the values for its arguments in parenthesis,
To call a function in another object there is an efun
call_other which can be abbreviated with
Functions and global variables can have modifiers to change the behaviour of the function resp. variable. The modifier is written just before the return type.
call_other(from this object or another object) will ignore this function.
call_other) will ignore this function.
0. Please note that calls via
call_otherare always treated as
save_objector restored by
asyncto be asynchronous. This means the function can suspend its execution at any time and be resumed later on. At each suspension a value can be passed in and/or out. To execute such a function a coroutine object must be created. This is similar to calling the function but will not start execution immediately, but only create the coroutine object. With a call to
await, the execution can be started/continued. Coroutines can call other coroutines either with
await. The former suspends execution only till the first suspension of the called coroutine, the later suspends execution until the called coroutine has ended. Previous Next