AddTriggerEx
Script function

world.AddTriggerEx

DOC_scripting Read about scripting

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);

DOC_data_types 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
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)

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;



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:

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

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

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
CustomOther = 16



Return value

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


DOC_errors View list of return code meanings


See Also ...

Topics

DOC_aliases Aliases
DOC_defaults Default triggers/aliases/timers/macros/colours
DOC_starting Getting started
DOC_group Groups
DOC_plugins Plugins
DOC_regexp Regular Expressions
DOC_timers Timers
DOC_triggers Triggers

Functions

FNC_AddTrigger AddTrigger (Adds a trigger)
FNC_DeleteTemporaryTriggers DeleteTemporaryTriggers (Deletes all temporary triggers)
FNC_DeleteTrigger DeleteTrigger (Deletes a trigger)
FNC_DeleteTriggerGroup DeleteTriggerGroup (Deletes a group of triggers)
FNC_EnableTrigger EnableTrigger (Enables or disables a trigger)
FNC_EnableTriggerGroup EnableTriggerGroup (Enables/disables a group of triggers)
FNC_GetPluginTriggerInfo GetPluginTriggerInfo (Gets details about a named trigger for a specified plugin)
FNC_GetPluginTriggerList GetPluginTriggerList (Gets the list of triggers in a specified plugin)
FNC_GetTrigger GetTrigger (Gets details about a named trigger)
FNC_GetTriggerInfo GetTriggerInfo (Gets details about a named trigger)
FNC_GetTriggerList GetTriggerList (Gets the list of triggers)
FNC_GetTriggerOption GetTriggerOption (Gets the value of a named trigger option)
FNC_GetTriggerWildcard GetTriggerWildcard (Returns the contents of the specified wildcard for the named trigger)
FNC_ImportXML ImportXML (Imports configuration data in XML format)
FNC_IsTrigger IsTrigger (Tests to see if a trigger exists)
FNC_SetTriggerOption SetTriggerOption (Sets the value of a named trigger option)

(Help topic: function=AddTriggerEx)

DOC_contents Documentation contents page