IMPERIAN'S INTERNAL ALIAS SYSTEM - Imperian Online Help

2.7 IMPERIAN'S INTERNAL ALIAS SYSTEM

An alias in Imperian is a combination of letters and/or numbers, with no
spaces.  Linked with this 'word' is a command. When you type the alias, the
command will be executed instead.

For example, if your alias was, 'sayhi' and the command associated with it
was 'say Hi everyone!' then every time you entered 'sayhi', then Imperian
would turn it into 'say Hi everyone!'.

Within aliases, you may embed what are called targets. Think of targets as
an alias within an alias. All targets in an alias must be preceded with a
& character.

So, for example, let's make the 'sayhi' alias from above a bit more
functional, so that it may be targeted to your guildmaster, whoever that
happened to be at the time.

You would first set your 'sayhi' alias to equal 'hi &gm', where 'gm' is the
target. You would then set that target to be the name of whoever your
guildmaster is. If you set the 'gm' target to be 'Gawain' then 'sayhi &gm'
would execute 'hi Gawain'.

It should be pointed out that generally you do NOT need 10 attack (for
instance) aliases. Instead of different aliases for 'attack hyena', 'attack
rat', etc, all you need to do is use a target. For example:

setalias ml attack &tar
settarget tar <whatever>

Set up all your attacking aliases to use target, and then when you want to
attack a new opponent, simply change the target, and all your attacking
aliases will now work on the new target.

You may name your aliases and your targets whatever you want, provided they
are 12 or fewer characters long. It is important that you do _not_ name
your aliases the same as any commands that you want to use, else the
commands will not work for you. When you type in EAT ASH, for instance,
Imperian will first search to see if you have an alias called "eat". If you
do, then it will try to execute that.

Alias substitution
------------------

In some situations, the basic functionality of aliases may not be enough. For example, you may want to create an alias that allows you to insert several different parameters. While you could do this by using several targets, such an approach would be rather tedious to use.

Instead, you can use substitutions. These are inserted by adding the $ character, followed by a number or an asterisk.

$1 is replaced by the first word that you type after the alias
$2 is replaced by the second word
...
$-1 is replaced by the last word of your command
$-2 is replaced by the second to last word
...
$0 is replaced by the alias name
$* is replaced by everything following the alias name

All words that were not included in the expansion list will be appended to the end of your alias. Including the $* sequence in your alias disables this behaviour.

Some examples:
SETALIAS ttt say $1 is here
Now 'ttt Bob' will expand to 'say Bob is here'
'ttt Bob again' will expand to 'say Bob is here again' - this is because there was no $2 expansion provided, and so the second word is added to the end
SETALIAS ttt say there is $1 and $3 and
Now 'ttt Bob Jane dog something' expands to 'say there is Bob and dog and Jane something' - the second and fourth words were appended to the end
SETALIAS ttt say $* is the sentence
'ttt blah blah blah' now expands to 'say blah blah blah is the sentence'

Command list:
-------------

SETALIAS <alias name> <substituted text> : Makes a new alias.
ALIASLIST/AL                             : Lists your aliases.
CLEARALIAS <alias name>                  : Clears an alias.

SETTARGET/ST <target name> <text>        : Makes a new target.
TARGETLIST/TARLIST                       : Lists your targets.
CLEARTARGET <target>                     : Clears a target.