Lua Funtioning

The core of the Lua coding system is its ability to interface with the MUD. Whenever Lua asks the MUD to perform a test or action, an 'actor' is necessary.

In some functions, that actor is assumed to be the mob the program is running on. For example, with 'say', we will only ever "say" as the mob a program running on - causing anyone else to say would be a "force". Example code snippets might be:

   say ("Hi!") -- mob says hi.
   echo ("This is an echo.") -- mob echos something
   rgoto ("aylor-0") -- mob goes somewhere

Other functions require the actor to be passed. For example, when we are testing if a character carries an item, we have to tell the MUD which character we are interested in.

    --- mob transfers player to aylor recall.
    transfer(ch,"aylor-231")

In test functions, we often want to test something on a character and the mob actually running the program is irrelevant (checing a player config flag or immunity). For other tests, we want to compare the player to the mob. For example:

    --- Is player immune to fire?
    if immune(ch,"fire") then ...

    --- Is player my ally? - mob needed in this case.
    if ally(ch) then ...

The function list below gives details on exactly what is required for each function and the options that can be used to modify their behavior

Lua / MUD Available Functions

We have tried to keep the syntax as close to the old mobprog syntax as possible for experienced builders. However, the extra options provided for in the Lua integration usually require option flags to be set. Where options are available, they are listed under each function.

The available functions to Lua can be broken down into a number of different categories:

Test Functions: These types of function don't actually do anything, but are available to test for various conditions in the MUD. In many cases, simple tests can be done using variable properties directly such as "if ch.int > 100 then". In other cases, more complex tests are needed such as if immune(ch,"fire") then. These types of function only ever return true or false.

Mud Info Retrieval: These types of function pull information from the MUD back into the Lua environment as needed. There are not many of these types of function as most of the data you will need is already available as variable properties. One example is temproom = getroom("aylor-0") which creates a ROOM type Lua variable for Aylor recall. Once temproom is available, you can use all the usual room properties on it such as temproom.healrate or temproom.people.

Actions: These functions cause the MUD to actually do something, such as transfer a character, send a message, cast a spell etc.

Goals and Tasks: This set of functions is used to control goal and task behaviour. They are documented separately on the goal and quest documentation page.

Object and Room Prog functions

Many functions require a "self" actor in order to operate and will not work with lua programs attached to objects and rooms unless those programs require a mob actor in the room. Each function is labeled to include their compatibility with object and room progs.

Note that many of the lua functions were originally created to be able to remove the old mobprog system as quickly as possible and are now being revisited for object and room progs. If you need a specific function to work on rooms or objects that is not yet available, please contact Lasher.