G G M u d

...a new powerful, opensource and multiplatform MUD client.

Lua Programming

Since version 0.5 GGMud implements a fairly complete LUA interface that let you program the client through this powerful scripting language. This manual will cover only the GGMud lua interface and will give some examples about how to use it, it will not cover the basics of LUA scripting, you can find everything you need in the LUA documentation or the LUA community site.

GGMud implements LUA 5.1, the interpreter is builtin in the executable so you don't need additional libraries to use it. The scripts should be ASCII files, the interpreter supports both DOS-like and unix-like files. The access to LUA script is provided in two different ways:

Available functions

From inside a LUA script you have access to a range of GGMud specific interface functions:

Variables & functions

Every global lua variable is visible to GGMud, every GGMud defined variable (with the #var command) is visible to the LUA scripts as global variable. So it's safe to assume that given a certain variable name their values in LUA and in the GGMud internal scripting engine is the same. Every GGMud variable is exported as string, anyway the weak type checking of LUA let you do arithmetical operations on these variables.

You can access any non local LUA function from GGMud, this can be useful to embed LUA code in you aliases, to call a LUA function you have to prefix his name with the & character, you can then include function parameters in between braces, the function must be called with the correct number of parameters or you will get a LUA runtime error.


NOTE: The save variables option in the preferences window can be used to save the value of the variables defined through the GGMud GUI or the #var command, so if you want to keep the value of a LUA variable across playing sessions you should define the variable in the GGMud interface and not in your LUA scripts, you cannot define it in BOTH places otherwise the last loaded value will be the variable value and this is not wanted.

Scripting examples

In this section there are some "real-world" scripting example that will give you the needed hints to be able to use the GGMUD LUA interface in a valuable way. The scripts will probably not be usable straight in your favourite mud since triggers works on EXACT strings and it's very difficult to find muds that use the same strings also if based on the same codebase.

Return to index