Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

[MUSHClient] - "Open-ended" aliases

MarielMariel Posts: 8Member
Hi everyone; this is a pretty simple question that I haven't been able to find the answer to (probably because I don't know the applicable terms).

I use MUSHClient and would like to know how to make an alias that replaces the first part of a command while leaving the rest of it blank, for me to fill in.
An example:
An alias "scry" to replace "cast scry at", so that during the game I can just input "scry Sartan" rather than "cast scry at Sartan".

Is there a way to do this with just aliases, or will I have to bring variables into play (the same way I would for a targeting system, for example)?



  • TrevizeTrevize Posts: 1,517Member @ - Epic Achaean
    I use regex, don't know about 'normal' aliases. In regex, it's be as simple as:

    ^scry (\w+)$

    send to: world

    cast scry at %1
    Current scripts: GoldTracker 1.2, mData 1.1
    Site: https://github.com/trevize-achaea/scripts/releases
    Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
    Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
  • DaeirDaeir AustraliaPosts: 6,276Member, Secret Squirrel @@ - Legendary Achaean
    edited March 2013
    Regex might be confusing for you if you've never used it before, but it's very handy. Let me break down what Trevize posted for you:

    ^scry (\w+)$

    This is what you'd call a matching pattern. The various characters mean different things depending on where they are in the pattern.

    ^ designates that the matching pattern will always be at the beginning of the line. This means that you won't match it when typing something like "say Daeir is so awesome, I'm going to scry him out." If you removed the ^ however, it would match whenever you typed scry <whatever>, but only if the <whatever> was the last thing in the line. More on that in a moment.

    The (\w+) is called a capture group. The only thing that is important here is whatever is in the brackets, because that is what determines what regex looks for. So, in this case, we have \w+. Breaking that up into it's two parts, we can look at \w and +. \w tells regex that it is only to look for word characters. Word characters being simple letters - no numbers, nothing else. Just letters. \w by itself will match just one word character, and that is what the + is for. + instructs regex to look for a match across as many characters as it is able to, from one to potentially all of the characters in the match.

    If the capture group was simply ^scry (\w)$ and you entered "scry mollusks", the game would receive "scry m", and send "cast scry at m". So you can understand why the + is important.

    And finally, the $ character is the opposite of the ^ character, meaning that we're telling regex that this match occurs before the end of the line it is sent in. That means that with ^ and $ encompassing your matching pattern, regex will only ever look for that pattern on its own, not inside any other text. So you can talk about scrying how awesome I am freely with anyone without your aliases going off. Moreover, if you removed the ^ and the $ character from the pattern, it would match anywhere you typed scry with a word beside it, so you'd find yourself randomly scrying people mid conversation if you spoke about scrying a lot.

    The most important thing to remember about this is the standard word matching group: (\w+). Some people use (.*) to encompass everything (it's basically a wildcard match) and it is a little easier to write, but is less precise and may cause you issues if your initial matching pattern is written incorrectly. But with everything encompassed in this small matching pattern, you have enough to make pretty fluid aliases.
Sign In to Comment.