MXP script routines
This dialog specifies the name of the script routines that are to be called if MXP is active.

Startup:

Called when MXP starts up.

eg.


sub OnMXPStartup
  Note "MXP starting up"
end sub


Shutdown:

Called when MXP closes down.

eg.


sub OnMXPShutdown
  Note "MXP closing down"
end sub


Opening tag:

Called for an opening tag.

This should be define as a function that returns a number.

If the value (a number) is not zero, then the tag will not be acted on. This lets you customise the way MUSHclient reactions to MXP/Pueblo tags. For example, you might want to omit tags that change the font color, or tags that underline text. See below for an example.

It is called in two places:

a) For the actual tag which appears in the MUD output; and
b) If this tag is a server-defined tag (using <!ELEMENT>) then for each of the "built-in" tags that the server-defined tag calls.

For example, if you had this definition:

<!ELEMENT foo "<b><i>" >

And later on the MUD sent:

<foo>Some text</foo>

The opening "<foo>" would cause the "MXP start tag" routines to be called for the following *three* tags:

i) foo
ii) b
iii) i

In other words, once for the actual tag sent (<foo>), and once each for the tags that are called *by* <foo>.

If the routine for "foo" returned true, then "foo" is cancelled and the following text is not set to italic, nor bold.

However if "foo" returns false, but "b" returns true and "i" returns false, then the text is merely made italic.

Here is an example of how you might write such a function:


function OnMXPStartTag (name, args, mylist)
if name = "foo" then OnMXPStartTag = false ' allow <foo>
if name = "b" then OnMXPStartTag = true ' disallow <b>
if name = "i" then OnMXPStartTag = false ' allow <i>
end function


Note that if you cancel a tag sent by the server, then you will probably get a "closing tag with no opening tag" warning (warning number 5005). You might want to suppress that if it gets annoying above for how to do that.

Closing tag:

Called for a closing tag.

It is passed two arguments - the name of the tag, and the "text" which is the data that appeared between the opening and closing tags.


sub OnMXPEndTag (name, text)

  world.AppendToNotepad "MXP", _
       "Closing tag: " + name + vbCRLF
  world.AppendToNotepad "MXP", _
       "Text: " + text + vbCRLF
end sub


Set variable:

This is called when a variable is set by MXP. You are passed two arguments, the variable name, and its new contents.


sub OnMXPvariable (name, contents)
  world.note "Var " + name + " set to " + contents
end sub


Error:

A script routine to be called on an MXP error.

If the value (a number) is not zero, then the error message will not be displayed in the message window. This lets you fine-tune the messages that appear there - for example, omitting errors or warnings that you are not interested in. Here is an example:

eg.


function OnMXPError (level, number, line, message)
  If number = 20001 then OnMXPError = true
end function



See Also ...

Topics

DOC_Arrays Arrays
DOC_lua_base Lua base functions
DOC_lua_bc Lua bc (big number) functions
DOC_lua_bit Lua bit manipulation functions
DOC_lua_coroutines Lua coroutine functions
DOC_lua_debug Lua debug functions
DOC_lua_io Lua io functions
DOC_lua_math Lua math functions
DOC_lua_os Lua os functions
DOC_lua_package Lua package functions
DOC_lua_rex Lua PCRE regular expression functions
DOC_lua Lua script extensions
DOC_lua_string Lua string functions
DOC_lua_tables Lua table functions
DOC_lua_utils Lua utilities
DOC_plugins Plugins
DOC_scripting Scripting
DOC_mxp_callbacks Scripting callbacks - MXP
DOC_plugin_callbacks Scripting callbacks - plugins
DOC_data_types Scripting data types
DOC_function_list Scripting functions list
DOC_errors Scripting return codes
DOC_utils Utilities
DOC_variables Variables
DOC_world World functions

Dialog

DLG_IDD_PREFS_P17 Scripts

(Help topic: dialog=IDD_MXP_SCRIPTS)

DOC_contents Documentation contents page