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

SetTriggerOption

Script function

world.SetTriggerOption

Read about scripting

Type

Method

Summary

Sets the value of a named trigger option

Prototype

long SetTriggerOption(BSTR TriggerName, BSTR OptionName, BSTR Value);

View list of data type meanings

Description

Sets the current value of a trigger option.

You must specify the name of an existing trigger, and a trigger option from the list given for GetTriggerOption. These are the same names as used in the XML world files for trigger options.

Note that you can neither get or set the "name" field. It is listed below for completeness in viewing triggers copied to the clipboard or in world files and plugins. You already know the name when getting the trigger option (it is TriggerName), and this function is provided to modify existing triggers, not rename them. To change the name of a trigger use ExportXML, modify the XML, and then ImportXML.

If SetTriggerOption is called from within a plugin, the triggers for the current plugin are used, not the "global" MUSHclient triggers.

For numeric options (such as "sequence") the supplied string will be converted to a number. It is an error if the string does not consist of digits (0 to 9). For the "user" option an optional leading sign is accepted.

For boolean options (such as "enabled") the supplied string may be:

"y", "Y", or "1" for true
"n", "N", or "0" for false

Also if you are using Lua you can supply simply true or false.

The various option names are:

"clipboard_arg": 0 - 10 - which wildcard to copy to the clipboard
"colour_change_type": 0=both, 1=foreground, 2=background
"custom_colour": 0=no change, 1 - 16, 17=other
"enabled": y/n - trigger is enabled
"expand_variables": y/n - expand variables (like @target)
"group": (string - group name)
"ignore_case": y/n - caseless matching
"inverse": y/n - only match if inverse, however see match_inverse
"italic": y/n - only match if italic, however see match_italic
"keep_evaluating": y/n - evaluate next trigger in sequence
"lines_to_match": 0 - 200 - how many lines to match for multi-line triggers
"lowercase_wildcard": y/n - make matching wildcards lower-case
"match": (string - what to match)
"match_style": (see below) - what style and colour combination to match on
"multi_line": y/n - multi-line trigger
"name": (string - name/label of trigger)
"new_style": (style(s) to change to: (bold (1) / underline (2) / italic (4) ) )
"omit_from_log": y/n - omit matching line from log file
"omit_from_output": y/n - omit matching line from output window
"one_shot": y/n - trigger is deleted after firing
"other_back_colour": (string - name of colour to change to)
"other_text_colour": (string - name of colour to change to)
"regexp": y/n - regular expression
"repeat": y/n - repeatedly evaluate on same line
"script": (string - name of function to call)
"send": (multi-line string - what to send)
"send_to": 0 - 14 - "send to" location (see below)
"sequence": 0 - 10000 - sequence in which to check - lower first
"sound": (string - sound file name to play)
"sound_if_inactive": y/n - play sound even if world inactive
"user": -2147483647 to 2147483647 - user-defined number
"variable": (string - name of variable to send to)


Options that match on colour, bold, inverse or underline are tested against the first matching character.


Send-to locations

"0" - send to MUD
"1" - put in command window
"2" - display in output window
"3" - put in status line
"4" - new notepad
"5" - append to notepad
"6" - put in log file
"7" - replace notepad
"8" - queue it
"9" - set a variable
"10" - re-parse as command
"11" - send to MUD as speedwalk
"12" - send to script engine
"13" - send without queuing
"14" - send to script engine - after omitting from output


Trigger match_style field will be as follows (in hex nibbles):

TBFS

T = what style to test
B = background colour
F = foreground colour
S = what style bits are wanted

Style bits:

NORMAL 0x0000 // normal text
HILITE 0x0001 // bold
UNDERLINE 0x0002 // underline
BLINK 0x0004 // italic (sent to client as blink)
INVERSE 0x0008 // need to invert it


MATCH_TEXT 0x0080 // match on text colour?
MATCH_BACK 0x0800 // match on background colour?
MATCH_HILITE 0x1000 // match on bold bit?
MATCH_UNDERLINE 0x2000 // match on underline?
MATCH_BLINK 0x4000 // match on blink?
MATCH_INVERSE 0x8000 // match on inverse?

Colours:

BLACK = 0
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
MAGENTA = 5
CYAN = 6
WHITE = 7


See the forum posting at http://www.gammon.com.au/forum/?id=4873 for more details about match_style.

An easier way of settting trigger options, particularly ones relating to matching style and colours, could be to use ImportXML.

See the forum posting at http://www.gammon.com.au/forum/?id=7123 for more details about ImportXML, and the "addxml" module supplied for Lua scripting.


Available in MUSHclient version 3.29 onwards.



VBscript example

world.SetTriggerOption "mytrigger", "match", "north"


Jscript example

world.SetTriggerOption ("mytrigger", "match", "north");


PerlScript example

$world->SetTriggerOption ("mytrigger", "match", "north");


Python example

world.SetTriggerOption ("mytrigger", "match", "north")


Lua example

SetTriggerOption ("mytrigger", "match", "north")


Lua notes

The "send_to" 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


You can use true, false or nil for boolean options.


Return value

eInvalidObjectLabel: The trigger name is not valid
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
ePluginCannotSetOption: The option is marked as non-settable (in a plugin or not)
eOK: set OK

View list of return code meanings

See Also ...

Topics

Aliases
Default triggers/aliases/timers/macros/colours
Getting started
Groups
Plugins
Regular Expressions
Timers
Triggers

Functions

(AddTrigger) Adds a trigger
(AddTriggerEx) Adds a trigger - extended arguments
(DeleteTemporaryTriggers) Deletes all temporary triggers
(DeleteTrigger) Deletes a trigger
(DeleteTriggerGroup) Deletes a group of triggers
(EnableTrigger) Enables or disables a trigger
(EnableTriggerGroup) Enables/disables a group of triggers
(GetPluginTriggerInfo) Gets details about a named trigger for a specified plugin
(GetPluginTriggerList) Gets the list of triggers in a specified plugin
(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
(GetTriggerWildcard) Returns the contents of the specified wildcard for the named trigger
(IsTrigger) Tests to see if a trigger exists
(StopEvaluatingTriggers) Stops trigger evaluation

(Help topic: function=SetTriggerOption)

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]