Scripts
This screen is used to define parameters for scripting MUSHclient. Scripting allows you to create custom triggers, aliases and timers that react in ways limited only by your imagination. Available script functions are documented under the Help menu -> Functions List. Scripting Language: Choose between Vbscript (a cut-down version of Visual Basic), JavaScript (a cut-down version of the Java language), PerlScript, Python, Lua, TCL or PHPscript. If you are planning to use PerlScript, Python, TCL or PHPscript you will need to download the script engine (DLL) and possibly other files from their web site(s). Lua 5.1 is supplied as part of the MUSHclient download. It consists of an extra DLL (Dynamic Link Library) - lua5.1.dll. The recommended language to use if you do not already have scripts is Lua. For one thing, Lua is automatically supplied with MUSHclient and is thus always available for scripts. Some extra functionality is available exclusively to Lua scripts. If you install plugins they can also do scripting. The script language used in a plugin can be different from the one used by the "main world". Enable script This must be checked to enable the scripting engine. Active/not active If you see the word "(active)" next to "Enable script" it means the script engine is currently active. If you see the words "(not active)" next to "Enable script" it means the script engine is not currently active. If it possible for the script engine to be active even with "enable script" unchecked, if you have just unchecked it, because the disabling is done when you close the preferences dialog. Similarly it is possible for the script engine to be inactive, even with "enable script" checked, because the enabling is done when you close the preferences dialog. Also, the script file may have caused a compile error, which means that the script was not successfully activated. Script File: This is optional, however normally if you are using scripting you would specify a script filename. You would type this in using any editor capable of producing ordinary "text" files, for example, NotePad. As a convention, a Vbscript file would have a suffix of ".VBS", a JavaScript file a suffix of ".JS", a PerlScript file a suffix of ".PL", a Python file a suffix of ".PYS", and a Lua file a suffix of ".LUA". If you specify a script filename, and check "Enable script" then MUSHclient will attempt to process that file when you close the "world configuration" dialog box. If any errors are detected you will be notified. Note however that some errors (such as "type mismatch", or "wrong number of arguments") are only detected when individual script subroutines are executed, and thus will not appear at this stage. Browse... Click on the "browse" button to locate a script file by using the file browsing dialog box. New... Click on the "new" button to create a script file by using the file browsing dialog box. If you choose a file name and click OK, then a new, empty script file of that name will be created for you. Edit Script By clicking on this button, your script file is opened in your specified editor (the default editor is Notepad). Choose Editor... Click on this button to choose a different editor to edit your script files. Use inbuilt notepad to edit scripts If checked, MUSHclient's internal notepad is used to edit scripts. Warn if inactive If checked, you will get a warning in the output window if a trigger, timer or alias tries to call a script (in the script file) but it cannot, because scripting is disabled, the function is not available, or the script file had a parse error. Note errors If checked, errors in scripts will be displayed in the output window (using world.Note) rather than having a dialog-box pop up at an inconvenient time. Note Colour: In the script language you can make "notes" which appear in the output window. You can choose which colour you want the notes to appear in. To make a note, you would say something like: world.Note "Here is a note" in your script. The colour is chosen from the world's custom colours pallette. You can change the colour for notes inside a script by using various script functions, such as world.ColourNote. World Events You can put the names for subroutines (functions) that you want called for the various events below. The name must match the name of a function in your world file. For example, if you specify "OnWorldOpen" for the "open" event below, then your script should look like this (in VBscript): sub OnWorldOpen ' process here world.Note "World has been opened" end sub Open: Called when the world file is opened (once per world). Connect: Called when the world connects to the MUD. You might use this to send initial commands needed after connection, or to enable/disable triggers etc. Get Focus: Called when the world gets the "focus". The focus is obtained when the particular world window becomes the active window (ie. the title bar changes to the active colour). Lose Focus: Called when the world loses the focus, as described above. Disconnect: Called when the world has been disconnected. Close: Called while the world is being closed. Save: Called just before the world file is being saved. You can use this event to save internal script variables to MUSHclient variables, so they are saved as well. MXP... Click to set extra script functions to be called when MXP is active. Register DLL If scripting is not working you can try clicking this to cause the script engine DLL to be "registered" with Windows. You should only need to do this once per PC. It is not necessary to do it for Lua, and is only implemented for VBscript, Jscript and PHP script. Recompile when script changes: When a script file changes MUSHclient may detect this (depending on the Operating System version). Select what behaviour you want when this happens: You can set the scripts to automatically recompile when you edit and save the script file by setting this option to "always". To ask whether ot not to recompile, set this option to "confirm". To never recompile, set this option to "never". Script Prefix: You can enter one or more characters here which will act as a "script language" prefix. The recommended prefix is the "/" character. If you type the "script prefix" in the command window, then the rest of the line is sent to the script engine. For example: /world.Close () would close the current world. See Also ... Topics Arrays Lua base functions Lua bc (big number) functions Lua bit manipulation functions Lua coroutine functions Lua debug functions Lua io functions Lua math functions Lua os functions Lua package functions Lua PCRE regular expression functions Lua script extensions Lua string functions Lua table functions Lua utilities Plugins Scripting Scripting callbacks - MXP Scripting callbacks - plugins Scripting data types Scripting functions list Scripting return codes Utilities Variables World functions Command ConfigureScripting (Sets scripting options) Dialog Immediate (Help topic: dialog=IDD_PREFS_P17) Documentation contents page