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

MUSHclient scripting

Description of MUSHclient world function: world.AddTriggerEx


Name AddTriggerEx
Type Method
Summary Adds a trigger - extended arguments
Prototype long AddTriggerEx(BSTR TriggerName, BSTR MatchText, BSTR ResponseText, long Flags, short Colour, short Wildcard, BSTR SoundFileName, BSTR ScriptName, short SendTo, short Sequence);

View list of data type meanings

Description

Adds a trigger to the list of triggers. If you are prepared to accept the default values for Sequence and "Send To" you can use AddTrigger instead.

For AddTrigger they default to:
Sequence: 100
Send to: world

Name: name of this trigger - may be empty (see rules for names below)
Match_text: what to match on
Response_text: what to send back to the world
Flags: various flags, see list below
Colour: what colour to draw triggered text, see list below
Wildcard: Copy which wildcard to the clipboard (0 = none), otherwise 1 to 10.
SoundFileName: Which sound file to play
ScriptName: Which script subroutine to execute
Sequence: Sequence number of trigger (lower is evaluated earlier). Must be in range 0 to 10,000
Send To: Where to send the trigger text to ...

0: World
1: Command window
2: Output window
3: Status line
4: Notepad (new)
5: Notepad (append)
6: Log File
7: Notepad (replace)
8: Command queue
9: Send To Variable
10: Execute (re-parse as command)
11: Speedwalk (send text is speedwalk, queue it)
12: Script (send to script engine)
13: Immediate (send to world in front of speedwalk queue)
14: Script - after omit (send to script engine, after lines have been omitted)


Flags

The flags can be one or more of the constants below. For example, to omit from log and omit from output, the flags would be 6. Preferably use the constant declarations in your script file, and "OR" them together. E.g.

VBscript: eOmitFromLog or eOmitFromOutput
JScript: eOmitFromLog | eOmitFromOutput

VBscript:

const eEnabled = 1 ' enable trigger
const eOmitFromLog = 2 ' omit from log file
const eOmitFromOutput = 4 ' omit trigger from output
const eKeepEvaluating = 8 ' keep evaluating
const eIgnoreCase = 16 ' ignore case when matching
const eTriggerRegularExpression = 32 ' trigger uses regular expression
const eExpandVariables = 512 ' expand variables like @direction
const eReplace = 1024 ' replace existing trigger of same name
const eTemporary = 16384 ' temporary - do not save to world file

JScript:

var eEnabled = 1; // enable trigger
var eOmitFromLog = 2; // omit from log file
var eOmitFromOutput = 4; // omit trigger from output
var eKeepEvaluating = 8; // keep evaluating
var eIgnoreCase = 16; // ignore case when matching
var eTriggerRegularExpression = 32; // trigger uses regular expression
var eExpandVariables = 512; // expand variables like @direction
var eReplace = 1024; // replace existing trigger of same name
var eTemporary = 16384; // temporary - do not save to world file

PerlScript constants:

$eEnabled = 1; # enable trigger
$eOmitFromLog = 2; # omit from log file
$eOmitFromOutput = 4; # omit trigger from output
$eKeepEvaluating = 8; # keep evaluating
$eIgnoreCase = 16; # ignore case when matching
$eTriggerRegularExpression = 32; # trigger uses regular expression
$eExpandVariables = 512; # expand variables like @direction
$eReplace = 1024; # replace existing trigger of same name
$eTemporary = 16384; # temporary - do not save to world file


Colours

VBscript:

const NOCHANGE = -1
const custom1 = 0
const custom2 = 1
const custom3 = 2
const custom4 = 3
const custom5 = 4
const custom6 = 5
const custom7 = 6
const custom8 = 7
const custom9 = 8
const custom10 = 9
const custom11 = 10
const custom12 = 11
const custom13 = 12
const custom14 = 13
const custom15 = 14
const custom16 = 15

JScript:

var NOCHANGE = -1;
var custom1 = 0;
var custom2 = 1;
var custom3 = 2;
var custom4 = 3;
var custom5 = 4;
var custom6 = 5;
var custom7 = 6;
var custom8 = 7;
var custom9 = 8;
var custom10 = 9;
var custom11 = 10;
var custom12 = 11;
var custom13 = 12;
var custom14 = 13;
var custom15 = 14;
var custom16 = 15;

PerlScript:

$NOCHANGE = -1;
$custom1 = 0;
$custom2 = 1;
$custom3 = 2;
$custom4 = 3;
$custom5 = 4;
$custom6 = 5;
$custom7 = 6;
$custom8 = 7;
$custom9 = 8;
$custom10 = 9;
$custom11 = 10;
$custom12 = 11;
$custom13 = 12;
$custom14 = 13;
$custom15 = 14;
$custom16 = 15;

* 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 (_)


Note: Available in version 3.18 onwards.


VBscript example
world.AddTriggerEx "", "* attacks", "You are under attack!", 1, 14, 0, "", "", 2, 50
Jscript example
world.AddTriggerEx ("", "* attacks", "You are under attack!", 1, 14, 0, "", "", 2, 50);
PerlScript example
$world->AddTriggerEx ("", "* attacks", "You are under attack!", 1, 14, 0, "", "", 2, 50);
Python example
world.AddTriggerEx ("", "* attacks", "You are under attack!", 1, 14, 0, "", "", 2, 50)
Lua example
AddTriggerEx ("", "* attacks", "You are under attack!", trigger_flag.Enabled, custom_colour.Custom15, 0, "", "", 2, 50)
Lua notes
The trigger sequence is optional and defaults to 100.

The trigger flags are built into the "trigger_flag" table, as follows:

trigger_flag.Enabled = 1
trigger_flag.OmitFromLog = 2
trigger_flag.OmitFromOutput = 4
trigger_flag.KeepEvaluating = 8
trigger_flag.IgnoreCase = 16
trigger_flag.RegularExpression = 32
trigger_flag.ExpandVariables = 512
trigger_flag.Replace = 1024
trigger_flag.Temporary = 16384
trigger_flag.LowercaseWildcard = 2048


The colour names for custom colours are built into the "custom_colour" table, as follows:

custom_colour.NoChange = -1
custom_colour.Custom1 = 0
custom_colour.Custom2 = 1
custom_colour.Custom3 = 2
custom_colour.Custom4 = 3
custom_colour.Custom5 = 4
custom_colour.Custom6 = 5
custom_colour.Custom7 = 6
custom_colour.Custom8 = 7
custom_colour.Custom9 = 8
custom_colour.Custom10 = 9
custom_colour.Custom11 = 10
custom_colour.Custom12 = 11
custom_colour.Custom13 = 12
custom_colour.Custom14 = 13
custom_colour.Custom15 = 14
custom_colour.Custom16 = 15
custom_colour.CustomOther = 16

The "SendTo" field can be specified using the "sendto" table in the Lua global address space, as follows:

sendto.world = 0
sendto.command = 1
sendto.output = 2
sendto.status = 3
sendto.notepad = 4
sendto.notepadappend = 5
sendto.logfile = 6
sendto.notepadreplace = 7
sendto.commandqueue = 8
sendto.variable = 9
sendto.execute = 10
sendto.speedwalk = 11
sendto.script = 12
sendto.immediate = 13
sendto.scriptafteromit = 14
Returns eInvalidObjectLabel: The trigger name is not valid
eTriggerAlreadyExists: A trigger of that name already exists
eTriggerCannotBeEmpty: 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
eTriggerSequenceOutOfRange: Sequence is not in range 0 to 10000
eTriggerSendToInvalid: Send to field is not in range 0 to 9
eOK: added OK

View list of return code meanings

Introduced in version 3.18

See also ...

Function Description
AddTrigger Adds a trigger
DeleteTrigger Deletes a trigger
EnableTrigger Enables or disables a trigger
GetTrigger Gets details about a named trigger
GetTriggerInfo Gets details about a named trigger
GetTriggerList Gets the list of triggers
GetTriggerOption Gets the value of a named trigger option
ImportXML Imports configuration data in XML format
IsTrigger Tests to see if a trigger exists
SetTriggerOption Sets the value of a named trigger option

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

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]