HOW TO Index...
How to install
Please see the "doc/build.txt" file which
comes with the MudTelnet distribution.
|
How to add a MUD
You can do this in 2 ways, the first way is you can do it manually, by
creating the right directories and files. The second way is you can use
the "mudtelnet_mkchar" script which comes with the MudTelnet distribution.
All this script does is it creates the directories and files for you.
If you run the script, it basically does what is described below for you.
If this is your first time, use the script, then you will see the file
formats. If you use UNIX regularly you will probably not use the script
again because you can probably create and/or modify the files quicker
by hand than running the script again...
If you want to create the MUD by hand though, this is what you do.
You can run MudTelnet and connect to a MUD without even creating a MUD
of course, but if you do this you may as well use telnet! The minimum
you have to do to create a MUD is you have to create a directory in
your home directory called .mudtelnet, and then inside this, create
a directory for your MUD, for example, for
Mortal Realms you might create an "mr" directory. Now create a directory
inside the MUD directory for your character (or logon). For example
you might create the directory "murk" for a character you are going
to call "Murk". Now MudTelnet will recognise a character called "mr/murk".
Having done this, although MudTelnet will recognise "mr/murk" (which
means you can now start MudTelnet with the command "mudtelnet -m mr/murk")
it still isn't any different to telnet. If you use the command
"mudtelnet -m mr/murk game.mortalrealms.com 5467" then you will be connected to
Mortal Realms, but again, you could have done
this with telnet and not bothered with the "-m mr/murk"!
Now for the useful bits. Create a file inside the "mr/murk" directory
called "config.txt" and make it look like this:
GameHost: game.mortalrealms.com
GamePort: 4321
Triggers: On
Scripts: On
Record: On
Now you have a useful feature at last! If you use the command
"mudtelnet -m mr/murk" then you will be connected to the MUD without
having to enter in the host and port! Woo hoo!
The "Triggers", "Scripts" and "Record" lines above mean that triggers
are enabled by default, scripts are enabled by default and recording
is on by default, these options can be set to "On" or "Off".
Note that this 2 tier directory structure isn't mandatory, you could
simple create a single "abs" directory in your ".mudtelnet" and put
all your files in there, which would allow you to connect with the
command "mudtelnet -m abs".
I bet your mind is blown so far.. well.. never mind.. check out the
next section to see how to create triggers..
|
How to setup triggers
You can do this in 2 ways, the first way is you can do it manually, by
creating the files (or entries in files). The second way is you can use
the "mudtelnet_mktrigger" script which comes with the MudTelnet distribution.
All this script does is change the configuration files for you.
If you run the script, it basically does what is described below for you.
If this is your first time, use the script, then you will see the file
formats. If you use UNIX regularly you will probably not use the script
again because you can probably modify the files quicker by hand than
running the script again...
If you want to create the MUD by hand though, this is what you do.
Let us assume that you have a MUD which you've called "mr" and a character
called "murk", as if created from the example in the
previous section. Inside the "murk" directory, create a file called
"triggers.txt". Put in a line which reads like this:
see "says 'hello'" send "say Hello there\n"
Basically this is a simple instruction to your mud client that says
when it sees a certain thing, it should send back something else! The
format is as follows:
see "X" send "Y"
DO include the double quotes!!
When X is seen from the mud, then Y is sent back. Notice that in the above
example "Y" ends with a "\n". The "\n" is taken to mean a "return". If you
don't include it then "Y" will be inserted into your buffer, but not sent
to the MUD! You will discover what effect this has if you try it.
Create as many such lines in the file as you like. If output from the MUD
matches more than one of the triggers then ALL the matching triggers will
be triggered, so if you were to put 5 lines like the hello example above
into your "triggers.txt" file, you are liable to respond to someone saying
hello to you by saying hello back 5 times!
There are also some advanced features, introduced in version 1.01. These
allow you to add tags to the triggers to change the way they work. There
are 3 tags currently supported, they are the "maxtimes" tag, the "matchstop"
tag and the "debug" tag. The "debug" tag is only for scripts and is covered
later in the "how to debug scripts" section.
The other 2 tags can be applied to stright triggers or scripts. The "maxtimes"
tag allows you to specify the maximum number of times a trigger can be
activated (since you started mudtelnet). This is good for logging in for
example. Try something like this:
see "Login:" send "NAME\n" maxtimes=1
This will only ever be triggered once.
The "matchstop" tag causes a trigger, if it matches, to stop any further
trigger matching. This means that all the triggers AFTER this trigger
won't be checked against. For example, try this:
see "says 'hello'" send "say hello\n" maxtimes=2 matchstop
see "says 'hello'" send "say hello yet again\n" maxtimes=1 matchstop
see "says 'hello'" send "say stop bothering me\n" maxtimes=1
see "says 'hello'" send "say im not talking to you\n"
The first one will match only twice, and prevent any of the others from
matching. The second will match once, and again stop the others from
matching. The third will match once but not stop the 4th from matching
simultaneously! The fourth will always match since it has no limit
specified. This should result in the following conversation:
You say 'hello'
Arkal says 'hello'
You say 'hello'
Arkal says 'hello'
You say 'hello'
Arkal says 'hello yet again'
You say 'hello'
Arkal says 'stop bothering me'
Arkal says 'im not talking to you'
You say 'hello'
Arkal says 'im not talking to you'
You say 'hello'
Arkal says 'im not talking to you'
You can achieve all sorts of odd effects this way, but don't get
bogged down going too mad writing endless intricate triggers when
it might be simpler to write a script!
|
How to setup scripts
Let us assume that you have a MUD which you've called "mr" and a character
called "murk", as if created from the example in the
previous section. If you have some triggers already you will have a
"triggers.txt" file inside the "murk" directory, if not, create it.
You should also create a directory called "scripts" in the "murk" directory.
The format for scripts is similar to the triggers, and they go into your
"triggers.txt" still. Script entries look like:
see "X" exec "Y"
"Y" is the name of a file inside your "scripts" directory. The file should
be executable.
If the mud "sees" "X", then "Y" is run... from now on, all output from the
MUD is sent to the running script, and any output from the script is sent
back to the mud! This means that "Y" can be an executable of any sort, it
can be a C program, a shell script, a perl script.. almost anything..
Try the following script called "hello.pl" (note that you need perl for this):
#!/usr/bin/perl
if ($ARGV[0] eq "") {
exit 0;
}
use IO::Handle;
STDOUT->autoflush(1);
while (<STDIN>) {
if ($_ =~ /^.*?([A-Za-z0-9]+) says \'hello\'.*$/) {
printf "smile\n";
printf "say hello $1\n";
}
}
exit 0;
Add an entry into your "triggers.txt" file similar to this:
see "start scripting" exec "hello.pl"
Now, logon and make sure your mud client gets to see the phrase "start
scripting", by saying it, or something... the script should now be active.
The script should respond to people saying hello now by smiling and
and saying hello back.
NOTE: MUDs such as Mortal Realms, brilliant
though they are, because of their VT102 display systems, they also present
a hazard to script writers! All those lovely VT102 codes will also get
sent to your script! Yuck.. now.. this can be quite helpful sometimes
because you can use them to see what is going on and control things
better than ever you could if you didn't get this information.. but..
the down side is you have to be aware of them and parse them! The above
script works fine on Mortal Realms if you
disable colour and VT102. It does not if you have them on. Here is another
more complicated script which is useful for a high level Monk character
AND works with VT102 and colour turned on:
#!/usr/bin/perl
# Quit if no working directory!
if ($ARGV[0] eq "") {
exit 0;
}
# Set autoflush on output so it isn't delayed \
getting back to the mud.
use IO::Handle;
STDOUT->autoflush(1);
# Main loop.
while (<STDIN>) {
if ($_ =~ /^.*\x1b\[0;36;40m\x1b\[0;33;40m(\S+) \
says \'(.*)\'$/) {
if ($2 eq "help") {
printf "say Sure, how can i help you $1?\n";
printf "say Try saying \"sanc\", \"giant\", \
\"bless\", \"eheal\", \"fury\", \"restore\" or \"remcurse\
\"!\n";
} elsif ($2 eq "sanc") {
printf "cast \"sanctuary\" $1\n";
} elsif ($2 eq "giant") {
printf "cast \"giant strength\" $1\n";
} elsif ($2 eq "bless") {
printf "cast \"bless\" $1\n";
} elsif ($2 eq "eheal") {
printf "cast \"enhanced heal\" $1\n";
} elsif ($2 eq "fury") {
printf "cast \"righteous fury\" $1\n";
} elsif ($2 eq "restore") {
printf "cast \"restore\" $1\n";
} elsif ($2 eq "remcurse") {
printf "cast \"remove curse\" $1\n";
} elsif ($2 eq "feast") {
printf "cast \"feast\"\n";
} elsif ($2 eq "remcurse") {
printf "cast \"feast\" $1\n";
} elsif ($2 eq "all") {
printf "cast \"sanctuary\" $1\n";
printf "cast \"giant strength\" $1\n";
printf "cast \"bless\" $1\n";
printf "cast \"enhanced heal\" $1\n";
printf "cast \"righteous fury\" $1\n";
}
} elsif ($_ =~ /^.*\x1b\[1;36;40m\x1b\[1;33;40m\
(\S+) tells you \'(.*)\'$/) {
if ($2 eq "farh") {
printf "cast \"farheal\" $1\n";
}
}
}
# Exit gracefully.
exit 0;
Future releases of MudTelnet will include options to automatically strip
out VT102 (and telnet) codes so that it is easier to write simple scripts
when you have VT102 and colour turned on.
Here are some more scripts:
1. A script to prevent idling.
2. Another script to prevent idling.
3. A script to play sounds to your mudding.
3. A script for Mortal Realms which rolls you a character with maximum stats.
|
Scripts are started passing a single argument to them, it is the directory
where the "triggers.txt" and "config.txt" files are, i.e. if you start mudtelnet
with "-m a/b/c" then it will be "$HOME/.mudtelnet/a/b/c". The initial current
working directory of the script will be interited from mudtelnet, and it will
be whatever directory mudtelnet was started in.
How to debug scripts
Note that these features were introduced in version 1.01!
The problem with scripts is knowing what input is coming from where, to
where, why and generally what is going on. Output from your scripts goes
to the MUD of course so it isn't always easy to debug in the normal way.
In order to help you, MudTelnet reads "stderr" from the scripts too. Unless
you specify debugging then this output is simply discarded. If you use a
"debug" tag on your script (in "triggers.txt") though, it can be sent to
the specified log file. Try this:
see "start scripting" exec "hello.pl" debug=hello.log
Errors from hello.pl will now be appended to the "hello.log" file (in
whatever directory you are running mudtelnet. Try the following "hello.pl"
changes:
#!/usr/bin/perl
if ($ARGV[0] eq "") {
exit 0;
}
use IO::Handle;
STDOUT->autoflush(1);
STDERR->autoflush(1);
while (<STDIN>) {
if ($_ =~ /^.*?([A-Za-z0-9]+) says \'hello\'.*$/) {
printf STDERR "I am resonding to $1.\n";
printf "smile\n";
printf "say hello $1\n";
}
}
exit 0;
In addition to responding.. you should now find that MudTelnet is logging
"I am responding to X" messages to your "hello.log" file! You can see live
updates to this file by issuing the UNIX command "tail -f hello.log".
If you specify "debug=onscreen" in your "triggers.txt" configuration file
then output will be to the screen where everything else is, note that the
contents of 2 files "outputprepend,txt" and "outputappend.txt" (read at
mudtelnet start time) will be pre and post fixed to the output. These
files can contain anything, including VT102 codes to make your errors
or debug output show up in bold, or colour, etc.
|
How to get more help!
Please try using the mudtelnet mailing lists.
Subscribe to the mudtelnet-users list, post your quesion, maybe someone
will be able to help you.
|
|