In this article I'll attempt to give basic instruction on the simplest of coding, specifically a targeting and bashing alias directed towards using the Mudlet client to play Achaea, a free download program that is arguably the fastest, most reliable and best supported MUD client around.
First some useful documentation:
We'll start out with creating a new alias. Needing at first a name, we'll call it Target.
Then we need the 'pattern' this is what you'll type in each time to fire this alias off.
In this case, I use ^t (.+)$
I know, I know, this looks like gobbledygook. But let's break it down, a simple lesson in a bit of regex (Regular Expression.)
The carat ^ - This 'anchors' the pattern, telling the client that the 't (and what follows)' will always come at the beginning of a line.
The t is our alias. So when we want to set a rat as our target, we'd type t rat, or for a goblin, t goblin.
The bit in brackets (.+) is the regex match, in this case it means a single character (signified by the .) and that it has one or more of the preceding element after it. This allows us to capture letters, punctuation, numbers, even whitespace.
Finally finishing the pattern is the $. This serves a lot like the ^ does, anchoring the end of the line. It tells the client not to keep looking and matching. Anchoring your aliases with the carat and dollar sign are simple ways of ensuring your scripting is tidy and ensures that the processing is optimal.
Now, we have our pattern defined. We want it do something when we use it.
target = matches
This line takes whatever was caught by the regex pattern (.+) and assigns it to a variable, in this case, target.
target = string.title(target)
This nifty little line takes whatever we assigned to the variable target, and capitalises the string. Turning t rat, into Rat, or Goblin. Very handy when highlighting your target for PvP
This line is my safety check, a coloured echo that tells me when I've changed my target and what I changed it to.
cecho("") denotes that it is to be a coloured echo
The \n inside the brackets tells the MUD to put it on a newline, this keeps things nice and tidy.
.. target .. calls the information from the target variable, to use it in our colour echo. Note that the "s are broken for this.
Now save your alias and open up a new one, we'll use our new hunting target in a very basic bashing alias.
Name the new alias Hunt or something appropriate, then in the pattern simple ^h$
This needs no special qualifiers and will execute everytime you type h alone on a line.
Finally, to tell it what to do,
send("kill " ..target)
In Achaea, the coders have instituted a kill command that allows you to use 'kill whatever' and it will make use of your highest strength bashing ability, whether it be the newbie kick, or a monk's lethal combo. If you wanted to do something in particular say perhaps a metamorph's maul it is easily replaced.
send("maul " ..target) would accomplish this for you.
And it's as simple as that! If you want to give it a try, why not create a character in one of the free to play MUDs from Iron Realms and join us, kill some rats, take on the goblins, perhaps one day you'll kill Ugrach, Undead Lord of the Underworld.