Problem with Aliases

Posted by Tia on Sat 13 Oct 2001 02:08 AM — 5 posts, 19,619 views.

#0
I'm having a problem with understanding how to use the aliases in general; the aliases in Zmud had less symbols and checkboxes, but I really want to know how to use MUSHclient as it's much faster than the version of Zmud I'm using.

One of the aliases I've tried making was something for "focus <direction> <target>". I shortened it to "fn" in Zmud, f standing for focus, and n being the direction north. (I had to make an alias for each direction though.) Then I would type fn x, where x is the first letter of my target's name.

However, when I tried this in MUSHclient, it ate up my "x", appearing only as "focus north". I've tried it with *s and the strange ^& thing I found in the website, but it only came out as "focus north *" or even "fn x".

Is there a way I can overcome this problem?
Australia Forum Administrator #1
This should be easy to do. You want to put in asterisks to match the wildcard text, and refer to them as %1, %2 etc. in the sent text. For instance:


Alias: f* *
Send: focus %1 %2


Now if you type: fn x

It will send: focus n x

This example only requires a single alias too.

Australia Forum Administrator #2
The only problem with the above solution is that it will match on any word starting with f, so that if you type:


froggle newt


it would send "focus roggle newt"

For a more precise solution you could use regular expressions, like this:


Alias: ^f([nsew]) (\w+)$
Send: focus %1 %2
Regular expression: checked


This looks a bit weirder but if very specific. It matches on:

  • Start of line (^)
  • Then the letter 'f'
  • Then one only of the letters 'n', 's', 'e', or 'w'
  • A space
  • One or more "word" characters (ie. letters) represented by \w (word character) followed by "+" (meaning one or more)
  • End of line ($)


The round brackets indicate which parts of the matched text are to be collected into the %1 and %2 fields.

This therefore will match on "fn blah" but not "find cave" - which is probably better for you.

Amended on Sat 13 Oct 2001 06:31 AM by Nick Gammon
#3
Thanks so much for the help =)

I've tried applying the alias you gave for other things, such as o([nsew]) for open <direction>, but it doesn't seem to work. Could you tell me how many other ways are there to end off the alias, and when can they be used?
Australia Forum Administrator #4
I would need to see the whole alias to comment, but first, the important thing is to check the "regular expression" box if you are using that sort of alias.

If you just want to have something like "on" being "open north" (and so on), then your idea should have worked. eg.


Alias: ^o([nsew])$
Send: open %1
Regular expression: checked


There is a file "RegularExpressions.txt" that is distributed with MUSHclient that explains the regular expression syntax in some detail.

Also, check out this web page:


http://www.gammon.com.au/mushclient/funwithtriggers.htm


Although it is talking about triggers, not aliases, a lot of the concepts are similar, and it describes quite a bit about using regular expressions.