Mark's Mud Client Manual


Table of Contents


About

Mmucl is maintained by Mark Patton, mpatton@jhu.edu.

The current development version of Mmucl, with which this manual was distributed, is 1.1.1.

You can find the latest news at the Mmucl homepage, http://idt.net/~tmtr01/mmucl/

Copying

Mmucl is "free"; this means that everyone is free to use it and free to redistribute it on a free basis. Mmucl is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of Mmucl that they might get from you.

Specifically, I want to make sure that you have the right to give away copies of Mmucl, that you receive source code or else can get it if you want it, that you can change Mmucl or use pieces of it in new free programs, and that you know you can do these things.

To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of Mmucl, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.

Also, for my own protection, I must make certain that everyone finds out that there is no warranty for Mmucl. If Mmucl is modified by someone else and passed on, I want their recipients to know that what they have is not what I distributed, so that any problems introduced by others will no reflect on my reputation.

The precise conditions of the licenses for Mmucl are found in the General Public License that accompanies it.

Overview

Mmucl is a MUD (Multi-User Dungeon) client. A MUD is a multi-player role-playing game that runs as a server on a remote host. The server accepts connections, receives input from users, decides what to do, and sends information back.

Most muds are text based. You can connect to and play on them with a simple telnet client, but that tends to be painful. Mud clients make mudding much more pleasant. They let you do all sorts of useful things such as automatically responding to certain patterns of mud output and making shortcuts for often used MUD commands.

Mmucl provides the features found in most mud clients such as support for ANSI color, triggers, command line editing, aliases, and macros to name a few. Mmucl's most powerful feature is its extensibility through Tcl scripts. See section Scripts, for more info.

Startup

Platforms:

Resource files:

Unix

The shell script mmucl starts Mmucl.

Usage: `mmucl [interface] [option]'

Interfaces:

`xterm'
Creates a floating toolbar for input and uses a xterm for display.
`console'
Uses the console for for input and display.
`tk'
Uses an internal terminal emulator for input and display.

The default, if interface isn't given, is `tk'.

Options:

`-exec script'
Evaluate script on startup.
`--help'
Print usage information and exit.
`--version'
Print version information and exit.

Other platforms

Use start_mmucl.tcl to start Mmucl.

mmucl.rc

If `~/.mmucl/mmucl.rc' exists, it is sourced on startup.

It should be used to define generic procedures and aliases. For some ideas, look at the example `mmucl.rc' distributed with Mmucl. Scripts specific to a character should be stored in that character's init file. See section char.

Tk.conf

If `~/.mmucl/Tk.conf' exists, it is loaded on startup. Mmucl loads its `Tk.conf' and then checks to see if the use defined one.

This is a .Xdefaults style resource file for modifying the look and feel of the `xterm' and `tk' interfaces.

You may want to use the `Tk.conf' Mmucl loads as a template. It explains the syntax of the file and changes that our often needed.

Quickstart

This chapter will walk you through some Mmucl basics to help you get started quickly. You may not necesarrily understand the alias and action examples below, but you can use them as templates and later read through section Scripts.

Whenever you type input into Mmucl it undergoes special interpretation. You might have run in to this if you noticed that `e;e' is equivalent to typing in `e' twice. To send a literal `;' to the mud prefix the string you want to send with `\'. For a more detailed description of how Mmucl handles input see section parse.

Make an alias name `h' to send the command `cast cure critical wounds me' to the mud.

alias set h {
    write "cast cure critical wounds me"
}

Even better, bind the command to a key. We'll bind it to F1.

key set <Key-F1> {
    write "cast cure critical wounds me"
}

Suppose we want to heal someone else? We'll make an h alias that heals someone else if given an argument and heals us if given no arguments.

The command % returns a list of all the arguments given to the alias. The `llength' procedure returns the length of the list given to it as an argument. In this case it checks to see if any arguments were given to the alias. To retrieve its first argument the alias uses % 1.

alias set h {
    if {[llength [%]]} {
        write "cast cure critical wounds [% 1]"
    } else {
         write "cast cure critical wounds me"
    }
}

Maybe we should heal ourselves automatically whenever we get `Bob CRUSHES you to the ground' send from the mud.

action set {Bob CRUSHES you to the ground} {
    write "cast cure critical wounds me"
}

How about generalizing the action so we get healed when any monster crushes us? We can use `%w' in the pattern to match the monsters name. (If the monster's name has spaces in it, use `%s' instead.)

action set {%w CRUSHES you to the ground} {
    write "cast cure critical wounds me"
}

One problem with the action is that someone could give us a tell, `bear CRUSHES you to the ground' and trigger the action. To prevent that we want to have the action only be triggered when `%w CRUSHES you to the ground' is at the beginning of a line. We can do that with `%^' which matches the beginning of a line.

action set {%^%w CRUSHES you to the ground} {
    write "cast cure critical wounds me"
}

Now suppose we want to automatically heal our friends when they tell us "heal me".

The `@' command in an action works like the `%' command in an alias except that `@' retrieves action matches.

action set {%^%w tells you: heal me} {
    write "cast cure critical wounds [@ 2]"
}

Scripts

Introduction

Tcl Syntax

The following rules define the syntax and semantics of the Tcl language and were taken directly from the man page Tcl(n).

  1. A Tcl script is a string containing one or more commands. Semi-colons and newlines are command separators unless quoted as described below. Close brackets are command terminators during command substitution (see below) unless quoted.
  2. A command is evaluated in two steps. First, the Tcl interpreter breaks the command into words and performs substitutions as described below. These substitutions are performed in the same way for all commands. The first word is used to locate a command procedure to carry out the command, then all of the words of the command are passed to the command procedure. The command procedure is free to interpret each of its words in any way it likes, such as an integer, variable name, list, or Tcl script. Different commands interpret their words differently.
  3. Words of a command are separated by white space (except for newlines, which are command separators).
  4. If the first character of a word is double-quote `"' then the word is terminated by the next double-quote character. If semi-colons, close brackets, or white space characters (including newlines) appear between the quotes then they are treated as ordinary characters and included in the word. Command substitution, variable substitution, and backslash substitution are performed on the characters between the quotes as described below. The double-quotes are not retained as part of the word.
  5. If the first character of a word is an open brace `{' then the word is terminated by the matching close brace `}'. Braces nest within the word: for each additional open brace there must be an additional close brace (however, if an open brace or close brace within the word is quoted with a backslash then it is not counted in locating the matching close brace). No substitutions are performed on the characters between the braces except for backslash-newline substitutions described below, nor do semi-colons, newlines, close brackets, or white space receive any special interpretation. The word will consist of exactly the characters between the outer braces, not including the braces themselves.
  6. If a word contains an open bracket `[' then Tcl performs command substitution. To do this it invokes the Tcl interpreter recursively to process the characters following the open bracket as a Tcl script. The script may contain any number of commands and must be terminated by a close bracket `]'. The result of the script (i.e. the result of its last command) is substituted into the word in place of the brackets and all of the characters between them. There may be any number of command substitutions in a single word. Command substitution is not performed on words enclosed in braces.
  7. If a word contains a dollar-sign `$' then Tcl performs variable substitution: the dollar-sign and the following characters are replaced in the word by the value of a variable. Variable substitution may take any of the following forms:
    `$name'
    Name is the name of a scalar variable; the name is terminated by any character that isn't a letter, digit, or underscore.
    `$name(index)'
    Name gives the name of an array variable and index gives the name of an element within that array. Name must contain only letters, digits, and underscores. Command substitutions, variable substitutions, and backslash substitutions are performed on the characters of index.
    `${name}'
    Name is the name of a scalar variable. It may contain any characters whatsoever except for close braces.
    There may be any number of variable substitutions in a single word. Variable substitution is not performed on words enclosed in braces.
  8. If a backslash `\' appears within a word then backslash substitution occurs. In all cases but those described below the backslash is dropped and the following character is treated as an ordinary character and included in the word. This allows characters such as double quotes, close brackets, and dollar signs to be included in words without triggering special processing. The following table lists the backslash sequences that are handled specially, along with the value that replaces each sequence.
    `\a'
    Audible alert (bell) (0x7).
    `\b'
    Backspace (0x8).
    `\f'
    Form feed (0xc).
    `\n'
    Newline (0xa).
    `\r'
    Carriage-return (0xd).
    `\t'
    Tab (0x9).
    `\v'
    Vertical tab (0xb).
    `\<newline>whiteSpace'
    A single space character replaces the backslash, newline, and all spaces and tabs after the newline. This backslash sequence is unique in that it is replaced in a separate pre-pass before the command is actually parsed. This means that it will be replaced even when it occurs between braces, and the resulting space will be treated as a word separator if it isn't in braces or quotes.
    `\\'
    Backslash `\'.
    `\ooo'
    The digits ooo (one, two, or three of them) give an eight-bit octal value for the Unicode character that will be inserted. The upper bits of the Unicode character will be 0.
    `\xhh'
    The hexadecimal digits hh give an eight-bit hexadecimal value for the Unicode character that will be inserted. Any number of hexadecimal digits may be present; however, all but the last two are ignored (the result is always a one-byte quantity). The upper bits of the Unicode character will be 0.
    `\uhhhh'
    The hexadecimal digits hhhh (one, two, three, or four of them) give a sixteen-bit hexadecimal value for the Unicode character that will be inserted. Backslash substitution is not performed on words enclosed in braces, except for backslash-newline as described above.
  9. If a hash character `#' appears at a point where Tcl is expecting the first character of the first word of a command, then the hash character and the characters that follow it, up through the next newline, are treated as a comment and ignored. The comment character only has significance when it appears at the beginning of a command.
  10. Each character is processed exactly once by the Tcl interpreter as part of creating the words of a command. For example, if variable substitution occurs then no further substitutions are performed on the value of the variable; the value is inserted into the word verbatim. If command substitution occurs then the nested command is processed entirely by the recursive call to the Tcl interpreter; no substitutions are performed before making the recursive call and no additional substitutions are performed on the result of the nested script.
  11. Substitutions do not affect the word boundaries of a command. For example, during variable substitution the entire value of the variable becomes part of a single word, even if the variable's value contains spaces.

Examples

Tips

Mmucl Procedures

These are procedure (actually they are aliases, see interp(n)) that Mmucl makes available to the user.

action

An action consists of a pattern and a script. When the pattern matches output from the mud, the script is evaluated.

Usage: action option ?args ...?

Options:

`set pattern ?script?'
If script is given create an action. If script isn't given, return the script associated with pattern.
`names ?pattern?'
Return all the action patterns that match pattern
`delete pattern'
Delete all the actions that match pattern.
`print ?pattern?'
Print to the display all the actions that match pattern.

Special characters in a pattern denote a "match". A "match" matches a type of string such as a number sent from the mud. Any other characters in a pattern must exactly match text from the mud.

Pattern matches:

`%^'
Match the beginning of a line.
`%c'
Match one character.
`%d'
Match a number
`%s'
Match anything up to the end of a line.
`%w'
Match a "word", a contiguous block of anything that isn't whitespace.

To disable the special interpretation of a match prepend `%' to it. For example if you want to match `%d' being sent from the mud, your pattern would be `%%d'.

Another special character is `*'. It matches anything. A literal `*' can be included with `**'.

@

Return an action match.

Usage: action ?index?

If index is `0' then @ returns the entire string the action matched. Otherwise @ returns the match corresponding to index. The index of a match is, moving from left to right, the nth match.

alias

An alias consists of a name and a script. When the first "word" of input matches an alias name, the script is evaluated

Usage: action option ?args ...?

Options:

`set name ?script?'
If script is given create an alias If script isn't given, return the script associated with name.
`names ?pattern?'
Return all the alias names that match pattern
`delete pattern'
Delete all the aliases that match pattern.
`print ?pattern?'
Print to the display all the aliases that match pattern.

%

Retrieve arguments given to an alias. Note that the `%' is only meaningful when called from within an alias.

Usage: % ?index?

If index, which should be a number, is given, return that argument to the alias. If index isn't given return a list of all the arguments given to the alias.

char

A char stores information about a character on a mud. Mmucl saves the information on exit and restores it on startup.

Usage: char option ?args ...?

Options:

`set name ?mud host port ?login?'
If only name is given, return a list of form {mud host port login}. Otherwise define a character. A init file for the character called name.mud will be created in `~/.mmucl/chars'.
`names ?pattern?'
Return all the char names that match pattern
`delete pattern'
Delete all the chars that match pattern.
`print ?pattern?'
Print to the display all the chars that match pattern.
`load name'
Connect to name's mud and load name's init file.

cline

Modify the current command line.

Usage: cline option ?args ...?

Options:

`delete first last'
Delete the text from first to last.
`get'
Return the current command line.
`insert index string'
Insert string into the command line at index.

color

Return a string with ansi text attributes.

Usage: color string colors ...

colors should be a list of the text attributes to apply to the string.

config

Change and inspect Mmucl config options.

Usage: config option ?args ...?

Options:

`set option ?value?'
If option is given, set option to value. Otherwise return option's value.
`names ?pattern?'
Return all the options that match pattern
`print ?pattern?'
Print to the display all the options that match pattern.

connect

Connect to a mud.

Usage: connect host port ?login?

Connect to host at port. If login, which must be a list, is given, each element of the list is written to the mud on a successful connection. The config option timeout determines how long connect waits for a response.

disconnect

Disconnect ends a connection to a mud.

Usage: disconnect

echo

Write to the display.

Usage echo str ?str ...?

Echo writes every argument, with a space added at the end, to the display.

exit

Log on to that strange place known as rl.

Usage: exit

getopt

help

Start an info browser to read Mmucl's info file.

Usage: help ?subject?

If subject is given go to node subject. Otherwise go to the Top node.

key

A key consists of an event and a script. When a sequence of keys matches an event, the script is evaluated. See bind(n).

Usage: key option ?args ...?

Options:

`set key ?script?'
If script is given, create a key. Otherwise return the script bound to key.
`names ?pattern?'
Return all the key names that match pattern
`delete pattern'
Delete all the keys that match pattern.
`print ?pattern?'
Print to the display all the keys that match pattern.

parse

Interpret a string just as if you'd typed it in.

Usage: parse str

If str begins with the config option `verbatim_char', by default `\', send str, minus `verbatim_char', to the mud.

If str begines with the config option `script_char', by default `/', str, minus `script_char', is evaluated as a Tcl script.

Barring the first two cases, str is split up into a sequence of substringss delimited by `;'. If the first "word" of a substring matches an alias, the alias is executed. Otherwise the substring is sent to the mud.

reconnect

Attempt to resume the last connection.

Usage: reconnect

save

Save Mmucl's state to a file.

Usage: save file

sub

A sub consists of a pattenn and a subspec (see regsub(n)). The sub replaces every occurence of its pattern in mud output with subspec.

Usage: `sub option ?args ...?'

Options:

`set pattern ?subspec?'
If subspec is given, create a sub. Otherwise return pattern's subspec.
`names ?pattern?'
Return all the sub names that match pattern
`delete pattern'
Delete all the sub that match pattern.
`print ?pattern?'
Print to the display all the subs that match pattern.

textin

Send a file to the mud.

Usage: textin file

write

Send strings to the mud.

Usage: write cmd ?cmd ...?

Each cmd is written to the mud.

Feedback

If you have comments, ideas, or suggestions, I'd be interested in hearing them. Bear in mind that I'm only interested in adding features that cannot be implemented in the user interp.

For bug reports I need to know your Mmucl version, Tcl version, operating system, and, if relevant, the address of the mud you are having a problem on

Mail feedback to mpatton@jhu.edu and please put "Mmucl" somewhere on the subject line.


This document was generated on 16 July 1998 using the texi2html translator version 1.52.