Using TinyFugue v5

Introduction

TinyFugue, aka "tf", is a flexible, screen-oriented MUD client, for use with any type of text MUD. As of writing this document I used TinyFugue 5.0 beta 8 which was released on January 14th, 2007.

Downloading and Installing

You can download the source for tf at tinyfugue.sourceforge.net. If you use windows you can probably either install Cygwin (which is a Unix like environment for Windows) and install it on there, or you can download an older pre-compiled package from www.druware.com. Some systems also come equipped with package systems and the ability to install tf on the fly. For example on Ubuntu you type sudo apt-get install tf5 and on OS X (with Darwin ports) you type sudo port install tf. There are other ways to get this of course too, but those are just a few examples.

If you do not need to compile tf you can skip to the next section.

If you downloaded the source package you are going to want to configure and make your binaries. To setup a very basic binary that works on most systems you are first going to have to extract the files.

$ tar xvzf tf-50b8.tar.gz
tf-50b8/
tf-50b8/CHANGES
tf-50b8/COPYING
tf-50b8/CREDITS
tf-50b8/Makefile.in
tf-50b8/README
... .. .

Now that you have your source files you are going to configure your tf. On most systems you can accept the default. Because I do not have root access on the machine to which I'm installing I'm going to set my prefix to my home directory. This makes sure that my binaries and help files only get installed on my local user. If you own the machine and have root access you can install it to /usr/local or something similar (if you have root and wish to install tf system wide you only need to perform the last step, make install, as root).

$ ./configure --prefix=/home/schrepfer
configure: Configuring TinyFugue version 5.0 beta 8
configure: 
configure: Core dumps disabled.
... .. .
## TinyFugue configuration successful.
## Use "make" to build.

Once you see 'configuration successful' you can move to the next step which is to compile the source code. You do this with the make command.

$ make
make[1]: Entering directory `/home/schrepfer/tf-50b8/src'
gcc -g -O2  -DDATADIR=/home/schrepfer/share   -c -o attr.o attr.c
gcc -g -O2  -DDATADIR=/home/schrepfer/share   -c -o command.o command.c
gcc -g -O2  -DDATADIR=/home/schrepfer/share   -c -o dstring.o dstring.c
... .. .
## TinyFugue build successful.
## Use "make install" to install:
##    tf binary: /home/schrepfer/bin/tf
##    library:   /home/schrepfer/share/tf-lib

Now that you've successfully compiled the code you can proceed to install your files to their final locations. You do this with the make install command (doing a system wide install needs root access here).

$ make install
make[1]: Entering directory `/home/schrepfer/tf-50b8/src'
if test -d ../help; then cd ../help; make tf-help; fi
if test -d ../help; then cp ../help/tf-help ../tf-lib; fi
... .. .
## TinyFugue installation successful.
##    tf binary: /home/schrepfer/bin/tf
##    library:   /home/schrepfer/share/tf-lib

Now your files should be installed to where you specified. You might need to edit your PATH variable depending on where your files are. You can do this inside of your terminal's profile.

Setting tf's Initialization Script (.tfrc)

In tf you can /load scripts as you need them. There is however one place where you should keep things which you would always like to load. This includes your worlds, a reconnect trigger, and maybe some common key bindings.

On Unix systems (this includes OS X) the .tfrc file lives in your home directory; for me it's in /home/schrepfer. If you use Windows (and are using wintf) this is going to be your My Documents folder. I believe that Cygwin follows the Unix standard and can be found in /home/schrepfer.

Setting up a world

You are going to want to use the /addworld command to add a new world. It takes quite a few parameters but I'll just show you a simple example to help you get by on ZombieMUD.

/addworld -T'lpp' zombie-conglomo conglomo *** zombiemud.org 23 ~/tf-trigs/load.tf

The -T parameter tells tf the kind of MUD to which you are connecting. ZombieMUD is an lpp style mud and has the GOAHEAD ability (which I will get into later) and this option ensures that /lp off is set (among other things). The zombie-conglomo is the name of my connection and it is the key which I use to refer to this world. The conglomo is my name and the text hidden by the *** is my password which is hidden. Having your username and password here is optional and you may omit them if you wish. Finally zombiemud.org 23 is the server and port to which I am connecting and the last parameter allows you to optionally give the name of the script you wish to load when connecting. You might or might not want this. tf will actually try and load this script each time you connect and sometimes this might not be the desired action. My load.tf is actually a script that loads only once.

/addworld -T'lpp' zombie-conglomo zombiemud.org 23

This example is much simpler. If you do not wish to save your password in a cleartext file this example would work well. If you leave out the password you need to leave out the username as well; it's all or nothing.

You can now connect to zombie by typing tf zombie-conglomo (or whatever name you used). Inside of tf you can use the /world command and type /world zombie-conglomo to have a similar effect. When you are finally connected to the MUD you should use the GOAHEAD option.

set use_goahead on
You set the value of variable use_goahead to "on".

With GOAHEAD on the MUD sends a special character at the end of lines and eliminates a pause after prompts. This gives the client a much more natural feeling.

A reconnect hook

One really important hook that I have setup on every different MUD to which I connect is a reconnect hook. This basically reconnects to the MUD when I lose connection. This could be because of Opoy or because the MUD reboots. The following is very simple but very nice to have.

/def -Fp1 -ag -h'CONFAIL|DISCONNECT' reconnect = /repeat -5 1 /world %{1}

This basically uses the /repeat command and tries to reconnect to the current world 5 seconds after the last failure.

Miscellaneous

Some other miscellaneous things that I have in my .tfrc are variables that control how tf behaves.

; history size
/histsize -l 20000
/histsize -g 20000
/histsize -i 2000 

; tf settings
/set max_trig=5000
/set warn_curly_re=off

The /histsize macros just control my buffer and command history. The max_trig variable lets tf know that I have a higher tolerance for the amount of triggers that set off. I have a lot of triggers and tend to overload the default values. If you do go over tf's commands/min your borg variable will be set to off (borg is short of Cyborg which just means triggers are on/off). The warn_curly_re just removes the warning when you use { or } in a regular expression (this didn't mean anything pre-tf5).

Creating a macro

You can create a macro with the /def command. This example is a simple macro that will take you from CS to your castle.

/def home = !11 e%;!3 s%;!3 e%; \
  !shoot home%;!enter

In short home is the name of this macro. You will execute it by typing /home. The text to the right of the equal sign (=) is the body of this macro. You separate commands in tf by combining the percent and semi-colon (%;). If you want a plain percent in a macro you need to use two percents (%%).

One final note before we move on; you can extend commands to multiple lines by adding a backslash (\) at the end of the line and then continuing the command below.

Creating a key binding

A neat way to execute commands or macros on the mud is to bind a key to it. tf has a simple way to bind keys by naming the macro a certain way and you can find more about this in the help. For this example I am going to bind F12.

/def key_f12 = !pull vine

tf knows that a macro named key_f12 should respond to a user pressing the F12 key on the keyboard. In this case it is going to send !pull vine to the MUD.

Creating some triggers

Like most MUD clients you can create triggers in tf. Here triggers are basically macros that can be set off with text from the MUD. There are three main matching patterns that you can use and each have their own uses. Check out patterns in the tf help.

simple

As the name says, simple is the simplest of triggers. It matches exact text from the MUD with no funny characters (except for escaping the quote characters). Using the /def command a simple new round trigger would look something like this.

/def -Fp5 -msimple -t'*NEW ROUND*' new_round = !scan

To summarize -F makes the trigger fall-through; that makes it so that other triggers that match this pattern with a lower priority will still be set off. The -p5 sets the priority to 5; you can set the priority to anything between 0 and MAX INTEGER but I like to use priorities under 10 and 5 is a good middle number. The -msimple sets the matching to be simple (this example). The -t'*NEW ROUND*' is the matching body. Finally the text to the left of the equal sign (=) is the name of this trigger; you can use this name to replace the trigger or to actually execute it from the command line by typing /new_round. Finally the text to the right of the equal sign is the action to perform. In this case we are sending the command !scan to the MUD.

This trigger will only match the text *NEW ROUND*. If there are extra spaces or extra characters there this trigger will not be set off.

glob

Globbing can best be compared to using a command shell or terminal. It expands the asterisk (*) to equal anything, much like how typing ls *.txt will list all files that end in .txt. There are more options which can be found by typing /help glob but for the most part you might as well use regexp if you need them. This next example is a stun spam trigger that just alerts players in the same room as you that you have stunned somebody.

/def -Fp5 -mglob -t'You STUN *.' stun = !think STUN

Most of the format of this trigger should be the same as the previous simple example except for the -mglob part. You will also notice that this uses the asterisk character in place of our target. You will also notice that if you did the simple example with globbing that the asterisks in *NEW ROUND* would have screwed up in places where you just saw the text NEW ROUND.

regexp

Finally the last and most powerful matching pattern is regular expressions. If you are not familiar with them you should learn them. Regular expressions allow you to not only match very specific patterns but also allows you to grab text from the MUD. You should definitely check out /help regexp for more information.

For example if you want to capture the name of somebody you just spanked you could do something like this.

/def -Fp5 -mregexp -t'^You spank (.+) hard on the butt\\.$' spank = \
  /set target_name=%{P1}

So as you can see it's a bit more complicated than the previous two examples. There's a lot more special keywords and things that you have to escape. In a quick/short summary, the period (.) matches any single character. The plus (+) sign will match one or more of the previous character and asterisk (*) will match zero or more of the previous character. The left and right parentheses are capturing groups; any text within those groups will be put inside of the %{Pn} variables.

In my example you will see that I started my line with a karat (^) and ended it with a dollar sign ($). This is because regular expressions will match text within a line and not necessarily match the whole line. I added those characters to the beginning and at the end because I wanted to make sure that the whole line matches.

You will also notice that I have a double backslash (\\) at the end of the line before the period and the dollar sign. This is because I needed to escape the period in order to match it. Because we are escaping a character within the regular expression and not the string itself we have to escape the first backslash with a second one so that the end result is to escape the period.

So with all that said and done, we capture the text between 'spank' and 'hard' and stick that inside of the target_name variable using capturing group 1 (%{P1}). You can capture other groups by replacing the 1 with 0 (entire expression), 2 (for second), 3 (for third), etc., see substitution for more details. If you do not use the carat and dollar sign you can match text before the regular expression and after with the %{PL} and %{PR} variables respectively.

Attributes

Adding attributes to your triggers basically tells tf how it should be displayed. With attributes you can gag the text, underline it, color it, make it blink, etc. You define attributes in any trigger with the -a option. I'll show you three examples; one for coloring the whole line, one partial highlighting and one for gagging text.

/def -Fp5 -msimple -aBCred -t'*NEW ROUND*' color_round

This trigger is almost exactly the same as the previous example but it adds -aBCred which basically means that it makes the text bold and red. You might also notice that there is nobody to this trigger and that is optional as all we wanted to do was color the text, nothing more.

If you wanted to do partial highlighting you would create a regular expression trigger and use -P in place of -a. By default -P will match the 0th group, but you can change it to match any combination of PL, P1, PR, etc.

/def -Fp5 -PLCred;BCwhite;RCblue -mregexp -t'Conglomo' conglomo_flag

This will color the left of my name red, my name a bold-white and the right of my name blue.

/def -Fp5 -msimple -ag -t'You are not in battle.' gag_not_in_battle

This trigger gags this text as it sees it. You should never see You are not in battle. from the MUD as long as this trigger exists.

Testing

You can test your triggers by using the /trigger command. For example if I wanted to test my new round trigger I could type something like this.

/trigger -n *NEW ROUND*
% All of the following macros would be applied:
% F          5 color_scan
% F          5 new_round
% Text would have triggered 2 macros.

As you can see it would have triggered my new_round and color_scan macros.

Evaluating

There is one more thing that is quite useful in triggers and that is knowing how to evaluate expressions. In general you evaluate text between $[...]. So for example if you wished to increment a counter you could do something like this.

/def addvar = \
  /set var=$[var+{1-1}]%; \
  /result var

This macro addvar will take the variable %{var}, evaluate it and add the parameter we supplied (or default 1 if we omit that). In command macros you can access command line arguments with %{1} for the first, %{2} for the second, and %{*} for all, etc. You should notice in this example that I removed the percent from the front of the variables; this is because it's inside of an evaluation body and you no longer need the percent to point out variables; in the case of these special variables like %{1} and %{P1} you are still required to have the curly brackets (custom variables should not have them). You should also notice that I turned %{1} to {1-1}; the -1 within the curly brackets tells tf my default value, this 1 could have been anything. By adding /result at the end of this macro body we essentially turned this macro into a function which can return a value. So now you could actually do something like this.

/eval /addvar%;/addvar 2%;/echo $[addvar(3)]
1
3
6

This simple macro can now be accessed as a command or a function with and without parameters. If you find you write a lot of macros with %{1}, %{2}, etc., you should definitely check out getopts; this is a powerful command line parser that you will love once you get the hang of it.

Screen

One thing that should be at least mentioned in this guide is screen. Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. In short, screen allows you to connect to the mud, disconnect and re-attach the session from anywhere. I, for example, have tf running in screen on a server in Finland. I can stay connected with my tf all of the time and just re-attach screen from home, work, etc. Screen is definitely worth checking out.

Summary

With this you should be able to setup tf and have some simple triggers working. Be sure to use /help as much as you can. There's a lot of useful information there. Feel free to contact me on ZombieMUD any time if you need help or have suggestions for this page.