Combining aliases with RegExp

Posted by Thaeldan on Sun 04 Mar 2001 04:20 PM — 1 posts, 10,994 views.

Norway #0
This tutorial will show you how to combine aliases into a single alias with MUSHClient's Regular Expression feature.

In this example we will create an alias that fetches a potion from a bag and then quaffs it.

The alias looks like this:

^(misty|orange|yellow|clear|green)$

Inside the parenthesis are the names of different potions separated by "|" which is the OR character for Regular Expressions. This means that it will only match one of the potions inside, but nothing else.

The "^" at the beginning tells MUSHClient to look for the potions only if they appear at the beginning of a line, this will prevent it from matching e.g.:

give green Thaeldan

The "$" at the end of the line, does the opposite of "^" telling MUSHClient that it will only match if you write a potions name without anything after it, thus eliminating e.g.:

yellow stone of brick

To add the alias, press Shift-Ctrl-9 on the keyboard, you should see a dialog similar to the one below:

Click "Add" and enter the alias as below:



Alias: ^(misty|orange|yellow|clear|green)$

Send: g %1 bag
      q %1

Enabled: checked
Regular expression: checked




The lines "g %1 bag" and "q %1" are what we will send to the mud, it's very basic. "g" is an abbreviation for "get" and "%1" is the first parameter passed by the alias, in our case one of the potions. Finally the "q %1" will quaff one of the potions.

To use the alias simply type e.g.: "misty" on the command line and press enter, this will send:


g misty bag
q misty


Neat huh? And all in one alias!

-Thaeldan