[Home] [Downloads] [Search] [Help/forum]

Aliases

Aliases let you respond to something you have typed.

For example, an alias "GF" might expand to "open bag; get food"

You can also make aliases invoke scripts, make notes on the screen, do speedwalks, and many other things.

To respond to some text arriving from the MUD, use a trigger instead.

You can use wildcards to put "variable" information into the alias. For example, say you want to make an alias that gets something from your bag, and quaffs it, but the "something" might change from time to time, use an asterisk to represent the unknown thing. For example:

Match: gq *


Send:

get %1 bag
quaff %1


Then you might type:

gq potion


You can have up to 999 wildcards (which become %1 to %9) with %0 representing "the whole matching text". See below for how to access the higher numbered wildcards.




Another example, which uses two wildcards, might be used if you had to prepare a spell before using it.

Match: c * *


Send:

prepare %1
cast %1 %2


Then you might type:

c heal gandalf





Alias scripts

Aliases can execute script commands by simply putting the command into the "send" box and selecting "send to script".

However for more complex scripts you can put scripts into your script file (see scripting configuration tab for the world) and then call the script from the alias. To do this put the name of the script subroutine into the alias's script box.

The script subroutine must* have three arguments, as follows:


  • Name of the alias
  • The matching line
  • An array of the first 10 wildcards


* If you are using Lua, then the arguments are optional, as usual.

An example script in the VBscript language would be:


sub MyAlias (name, line, wildcards)
  Note "Alias " & name & " matched."
  Note "Wildcard 1 was" & wildcards (1)
end sub


Wildcard 10 is the entire matching sequence, which is not necessarily the same as the matching line in the case of regular expressions.

Other wildcards can be accessed by using the GetAliasWildcard script routine (for example, named wildcards, or wildcards over number 9).




Wildcards

A powerful feature in matching triggers or aliases is the ability to specify "wildcards" which are variable information that might change from time to time.

For example:


k *


In this case the asterisk represents the name of the unknown target you wish to kill.

Using the wildcard in the "send" box ...

To use this unknown quantity you can refer to it as %1 (for the first wildcard) in the "send" box, like this:


kick %1


The second wildcard is %2, and so on. Wildcard %0 is a special case which represents the entire matching text.

For wildcards above 9 you can use this syntax:


kick %<22>


The number in the angled brackets can be from 0 to 999.

Also, if you use regular expressions, you can name wildcards, like this:


^k (?P<target>.*)$


This names the wildcard as "target". You can then use this name in a similar way:


kick %<target>


See Also ...

Topics

Auto-mapper
Default triggers/aliases/timers/macros/colours
Getting started
Groups
Keypad navigation
Macro keys
Plugins
Regular Expressions
Speed walking
Timers
Triggers

Command

(ConfigureAliases) Define aliases

Dialogs

Alias configuration (list)
Edit alias

Functions

(AddAlias) Adds an alias
(DeleteAlias) Deletes an alias
(DeleteAliasGroup) Deletes a group of aliases
(DeleteTemporaryAliases) Deletes all temporary aliases
(EnableAlias) Enables or disables an alias
(EnableAliasGroup) Enables/disables a group of aliases
(GetAlias) Gets details about an alias
(GetAliasInfo) Gets details about an alias
(GetAliasList) Gets the list of aliases
(GetAliasOption) Gets the value of a named alias option
(GetAliasWildcard) Returns the contents of the specified wildcard for the named alias
(GetPluginAliasInfo) Gets details about a named alias for a specified plugin
(GetPluginAliasList) Gets the list of aliases in a specified plugin
(GetPluginAliasOption) Gets the value of a named alias option for a specified plugin
(IsAlias) Tests to see if an alias exists
(SetAliasOption) Sets the value of a named alias option

(Help topic: general=aliases)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]