Aliases

One of the most popular uses of clients is the use of Aliases. Many muds have these build in, but you will soon find out that MonkeyTerm can do much more with alises than most other clients or muds can. Simple aliases span from things as simple as abreviating a long command into a few letters to a complex patterns checking your spelling or launching powerful scripts to rule the world, err.. mud.
An alias will execute a command (or simply send some text to the mud) based on the command (or text) you type in the little white chat-window in the bottom of the screen. Simple aliases will simply match an exact word you type and send a static result to the mud. A little more sofisticated example will take some part of the typed input and use it for the output send to the mud which will be shown in the first example. Finally you can use powerfull Regular Expression matching on your alias yielding immense power, this will be illustrated in the last example.

Let us look at a simple alias. Press F5 and look at the FMT.
This alias will loot everything from a corpse.

Alias Name: Choosing a unique name for your alias is important. This is the only way MonkeyTerm can keep track of what alias is in question for both viewing in the FMT and indexing through scripting. You will often see names contain a slash / character, and the reason for this is to help group certain aliases, actions etc. together. The name of this alias is tools/gac and not just gac. The way the FMT shows this is by showing a banana icon named gac in a folder called tools. If we renamed the alias to default/gac then the alias would be moved into the default folder instead.

Pattern: Many clients use the name of the alias to actually trigger it, meaning once you type the name of the alias it will start executing the commands you gave it. MonkeyTerm is a bit different to help both the novice user and the advanced one. Instead of having to type tools/gac you can define a pattern that this alias will trigger on. In this simple example typing gac will let MonkeyTerm execute the commands. You will see a much more advanced use of the pattern field in the next example so if you're not impressed yet don't worry :)

Commands: When you create an alias you do it because you want it to execute one or more commands for you easily, without you having to type it all. Well these commands must be entered in this field. In this simple example anything entered into the commands field will be send to the mud (actually it will be parsed first but don't worry about that yet). There are a few things to be aware of when handleing aliases, scripts or any other item in the FMT. MonkeyTerm provides you with some tools to parse special values. Examples of this is the % sign. MonkeyTerm will replace the %1 just before it send the command to the mud, but what will it be replaced with? Read more about that here. If you start the alias by simply writing gac then %1 will be replaced with an empty string (nothing) and the result send to the mud will be get all corpse. The interesting part is when you type a little more. If you enter gac 2. then MonkeyTerm will replace the %1 with 2. sending get all 2.corpse to the mud.

Case sensitive: When this is checked MonkeyTerm will only match the alias if you type in the pattern with the right case, meaning it will not work with GAC or Gac but only with gac.

Active: Turning this off will disable the alias, making it never trigger or send commands to the mud. This feature is nice to have in some cases and instead of disableing it through the FMT hardcore users often disable and enable aliases, actions etc. through scripts.

Simple Pattern: Simple patterns are GLOB matches. If this is turned off the pattern will be a Regular Expression instead. Read more about that here.


Ok, let's look at a more complicated example:
This alias will enable speedwalk, and is filled with nice examples. I will only comment a few things, the rest can be used as a teaser :)

We have exatcly the same fields to edit in as like we had in the first example. There are a few things to notice though. First observe that the Simple Pattern has now been turned off, meaning the pattern wil now be a Regular Expression match. Also the pattern itself no loger looks like a simple alias or name you can enter, this illustrates the power of using Regular Expressions for your matches. If we finally look at the commands you will notice that it has been enclosed by some script tags <% and %> these are used to tell MonkeyTerm not to send the result to the mud but instead run it through the internal scripting engine.

The pattern: Instead of going into a deep description of the pattern you should read up on Regular Expressions. The pattern itself matches the following: Match starts at the beginning of a line, followed by a sequence of minimum two characters that are either one of the letters n,s,e,w,u,d or a number. The pattern can then be followed by zero or more whitespaces (whitespaces are space, tab and a few other characters), then following that the line must end (you will have pressed the enter key). An example of something that will match this pattern is sseeees or 2s4es. As you can see those are standart speedwalks.

The Commands: As mentioned before all the commands are enclosed in script tags. MonkeyTerm uses VBScript for script language so knowing a little VBScript is required to understand any of this section. Basically what the script does is it read the value of the entered pattern and loads it into a variable called s. Notice how $0 was used to capture the whole alias entered and not just the first word entered after the alias as it was the case in the first example. Also notice that $0 was used instead of %0 to make the value usable for scripting.Read more about that here. the script then checks if the pattern (speedwalk) is news in which case it does not execute the speedwalk news but instead sends the normal command news to the mud. This was done so AstroMUD users can read the news without having to turn off speedwalks. If this is not the entered pattern the script will then try to read each direction and how many times you want to walk in that direction. By writing = c & vbLf you will actually send the result of the variable c followed by a Linefeed to the mud (to be more correct it will add it to a buffer and not send the result till the script is done running).


That was two examples illustrating the use of aliases. The possibilities are much greater though, but now it's up to you to utilize that.