tkMOO-light

Programmable Plugins

Plugins are short scripts written in the TCL programming language which allow you to customise the client and to add new functionality.

To use a plugin simply copy them to your /plugins/ directory. Then start the client and it will load each plugin. The /plugins/ directory should be in one of the following locations depending on the type of system you're using:

    unix:   ~/.tkMOO-lite/plugins
    mac:    PREF_FOLDER:plugins
    pc:     plugins directory in the same directory as the 
            tkmoo.tcl script.

Programming Examples

Controlling the Status Bar

The client's status bar consists of a series of display areas positioned below the pink input window. A general message display is arranged on the left and any number of additional Tk widgets arranged on the right. In order to keep the client's screen footprint to a minimum the status bar message region is only displayed if other statusbar widgets are present or if some message needs to be displayed.

The text to be displayed on the status bar can come from any source and the client's API has been extended to make it easy for code to modify the text displayed. In this screenshot the local time for a mud in Texas is being displayed. The message is actually composed on the mud and transferred to the client using a simple XMCP/1.1 message. A small plugin script handles the XMCP/1.1 message and displays the message.

Checking for mail

The green widget is displaying the current status of the mail queue on my UNIX computer. The checkmail plugin contains code to add the widget to the status bar and knows how to monitor the user's mailbox for new mail. This widget can be controlled using the Preferences Editor, you can decide whether or not you wish it to be displayed and which mail folder to monitor.

Monitoring your time online

The gold widget shows you how long you've been connected to the current site. Whenever you connect to a site the widget resets the timer and starts ticking. A plugin contains code to add the widget to the status bar. This widget can be controlled using the Preferences Editor, you can decide whether or not you wish it to be displayed for a given site.

Adding a new command to the Triggers

The Triggers in the client are designed so that you can't inadvertantly damage the internal workings of the client. In TCL terminology they exist inside a 'safe interpreter'. In order to expand the range of commands the Triggers have access to you sometimes need to create the commands separately and make them available to the Triggers by using the edittriggers.register_alias call. A plugin is the ideal way to do this.

Here's an example plugin that allows Triggers to detect incoming paged messages and which displays them inside their own dialog box.

    #   
    #       popup.tcl
    #   

    client.register popup start

    proc popup.start {} {
        edittriggers.register_alias dialog popup.dialog
    }

    proc popup.dialog { {message ""} } {
        set popup .[util.unique_id popup]
        toplevel $popup
        label $popup.l -text $message -font {helvetica 10} -bd 1 -relief raised
        button $popup.b -text Ok -command "destroy $popup"
        pack $popup.l -side top -fill x
        pack $popup.b -side bottom
    }
 
    window.displayCR "Loading popup.tcl"
This plugin creates a new command dialog which your Triggers can use. You need to add a new Trigger to your client which calls this new command. Select the 'Tools->Edit Triggers' menu option and type in the following code:
    trigger -regexp {^(.*) pages, (.*)} -command {dialog "$m1 pages, $m2"}
This trigger detects lines like:
    Andrew pages, "Hi!"
And then produces the following simple dialog box: