Scripting
Scripting lets you extend the behaviour of MUSHclient to do almost anything you want. You can script in one of (currently) eight script languages: VBscript, JScript, PerlScript, Tcl, Python, Lua, TCL and PHPscript. If you use plugins you can also have multiple script languages per session (a different one per plugin). We recommend using Lua as the preferred scripting language nowadays. Lua ships with MUSHclient, so scripts written in Lua will be more easily exchanged with other MUSHclient users. Also Lua can be used if running under Wine on Linux PCs. The Lua script DLL is shipped with MUSHclient. With the exception of Lua, VBscript and JScript, you will need to download and install the other script engines before using scripts written in those languages. How do scripts get called? MUSHclient will call a function (or subroutine) in your script at various places you can specify. For instance, each trigger, timer or alias can call a script. Information about the trigger, alias and timer (such as its name, and the matching line) is passed to the script routine so it can react appropriately. For example, you might make a trigger script that kept count of the number of times you levelled when playing a MUD. You can also specify that scripts get called when other events happen, like "world open", "world connect", "new chat user" and so on. How do scripts communicate with MUSHclient? Scripts use the COM (Component Object Model) technology to send requests to MUSHclient or ask for information (except for Lua, see below). For example, you can use "Note" to tell MUSHclient to put a note in the output window, or "GetInfo" to find out information about the current world (like when it was connected). Scripts use the "world" COM object to do this - this is available in all script languages. For example: world.Note "Hello, there" Lua scripting Lua scripting does not use COM, and can thus be used in situations (like running under Wine on Linux) where COM is not working reliably. Lua scripts are called directly from MUSHclient, generally with the same arguments as the COM scripts. There are some minor exceptions, these are noted under the relevant entries for each script function. Where do scripts go? You have a number of options for placing script routines - 1. In a script file which is used by the world (these can be shared between worlds). 2. Each plugin you install can have scripts in it. 3. Triggers, aliases and timers can call a script functions directly from inside them, without needing a separate script file. This is called "send to script". Script functions There is extensive documentation about the script functions, including a list of all of them, at the web page: http://www.gammon.com.au/mushclient/functions.htm Lua Commencing with version 3.52, the Lua language is supported. You can read more about Lua at: http://www.lua.org/ Unlike the other languages, support for Lua is "hard-coded" into MUSHclient, it does not use the COM (Component Object Model) interface. This allows Lua to be supported in a consistent way, even on platforms that do not support other languages (eg. Linux). Forum posting about scripting There is a lengthy post on the MUSHclient forum about using scripting, see this: http://www.gammon.com.au/forum/?id=6030 Functions ... Scripting functions list See Also ... Topics Arrays Lua script extensions Plugins Scripting callbacks - MXP Scripting callbacks - plugins Scripting data types Scripting functions list Scripting return codes Utilities Variables World functions Commands ConfigureScripting (Sets scripting options) EditScriptFile (Edits the current script file) Immediate (Allows testing of scripts) SendToScript (Sends the selection to the script engine of the related world) Dialogs Debug Global preferences - Lua Immediate Missing script procedure names MXP script routines Scripting Error Scripts (Help topic: general=scripting) Documentation contents page