world.AddAlias

MUSHclient script function (Method)

Adds an alias

Prototype

long AddAlias(BSTR AliasName, BSTR MatchText, BSTR ResponseText, long Flags, BSTR ScriptName);

Data type meanings

Description

Adds a alias to the list of aliases.

Name: name of this alias - may be empty (see rules for names below)
Match_text: what to match on
Response_text: what to send to the world
Flags: various flags, see list below
ScriptName: Which script subroutine to execute

Flags

The flags can be one or more of the constants below. For example, to enable the alias, and ignore the case of what was typed, the flags would be 33. Preferably use the constant declarations in your script file, and "OR" them together. E.g.

VBscript: eEnabled or eIgnoreAliasCase
JScript: eEnabled | eIgnoreAliasCase

VBscript constants:

const eEnabled = 1 ' enable alias
const eKeepEvaluating = 8 ' keep evaluating
const eIgnoreAliasCase = 32 ' ignore case when matching
const eOmitFromLogFile = 64 ' omit this alias from the log file
const eAliasRegularExpression = 128 ' alias is regular expressions
const eExpandVariables = 512 ' expand variables like @direction
const eReplace = 1024 ' replace existing alias of same name
const eAliasSpeedWalk = 2048 ' interpret send string as a speed walk string
const eAliasQueue = 4096 ' queue this alias for sending at the speedwalking delay interval
const eAliasMenu = 8192 ' this alias appears on the alias menu
const eTemporary = 16384 ' temporary - do not save to world file

JScript constants:

var eEnabled = 1; // same as for AddTrigger
var eKeepEvaluating = 8; // keep evaluating
var eIgnoreAliasCase = 32; // ignore case when matching
var eOmitFromLogFile = 64; // omit this alias from the log file
var eAliasRegularExpression = 128; // alias is regular expressions
var eExpandVariables = 512; // expand variables like @direction
var eReplace = 1024; // replace existing alias of same name
var eAliasSpeedWalk = 2048; // interpret send string as a speed walk string
var eAliasQueue = 4096; // queue this alias for sending at the speedwalking delay interval
var eAliasMenu = 8192; // this alias appears on the alias menu
var eTemporary = 16384; // temporary - do not save to world file

PerlScript constants:

my $eEnabled = 1; # same as for AddTrigger
my $eKeepEvaluating = 8; # keep evaluating

my $eIgnoreAliasCase = 32; # ignore case when matching
my $eOmitFromLogFile = 64; # omit this alias from the log file
my $eAliasRegularExpression = 128; # alias is regular expressions
my $eExpandVariables = 512; # expand variables like @direction
my $eReplace = 1024; # replace existing alias of same name
my $eAliasSpeedWalk = 2048; # interpret send string as a speed walk string
my $eAliasQueue = 4096; # queue this alias for sending at the speedwalking delay interval
my $eAliasMenu = 8192; # this alias appears on the alias menu
my $eTemporary = 16384; # temporary - do not save to world file

* Rules for names

Names of triggers, aliases, timers and variables must follow these rules:

a. Start with a letter (A-Z)
b. Be followed by letters (A-Z), numbers (0-9) or the underscore character (_)

VBscript example

world.addalias "food_alias", "eat", "eat food", eEnabled, ""

Jscript example

world.AddAlias("food_alias", "eat", "eat food", eEnabled, "");

PerlScript example

$world->AddAlias("food_alias", "eat", "eat food", $eEnabled, "");

Python example

world.AddAlias("food_alias", "eat", "eat food", eEnabled, "")

Lua example

AddAlias("food_alias", "eat", "eat food", alias_flag.Enabled, "")

Lua notes

The script name is optional.

The alias flags are built into the "alias_flag" table, as follows:

Enabled = 1
KeepEvaluating = 8
IgnoreAliasCase = 32
OmitFromLogFile = 64
RegularExpression = 128
ExpandVariables = 512
Replace = 1024
AliasSpeedWalk = 2048
AliasQueue = 4096
AliasMenu = 8192
Temporary = 16384

Return value

eInvalidObjectLabel: The alias name is not valid
eAliasAlreadyExists: A alias of that name already exists
eAliasCannotBeEmpty: The "match_text" cannot be empty
eScriptNameNotLocated: The script name cannot be located in the script file
eBadRegularExpression: The regular expression could not be evaluated
eOK: added OK

Return code meanings

Related topic

Aliases

See also

FunctionDescription
DeleteAliasDeletes an alias
DeleteAliasGroupDeletes a group of aliases
DeleteGroupDeletes a group of triggers, aliases and timers
EnableAliasEnables or disables an alias
EnableAliasGroupEnables/disables a group of aliases
EnableGroupEnables/disables a group of triggers, aliases and timers
GetAliasGets details about an alias
GetAliasInfoGets details about an alias
GetAliasListGets the list of aliases
GetAliasOptionGets the value of a named alias option
ImportXMLImports configuration data in XML format
IsAliasTests to see if an alias exists
SetAliasOptionSets the value of a named alias option