Register forum user name Search FAQ

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

Arrays
Database (SQLite)
Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua LPEG library
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua SQLite (database) interface
Lua string functions
Lua syntax
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

Dialog

Scripts

(Help topic: dialog=IDD_MXP_SCRIPTS)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.