Veilrunner Help · Scripting

Triggers

A trigger watches the text arriving from the MUD and reacts when a line matches.

Create a trigger

#trigger {pattern} {action}

#action, #tr and #act also work.

  • The action can be text to send, several commands split by ;, or local # commands. For example, #var stores matched text, and #showme prints a note only you see.
  • Patterns are literal text unless you turn on regex for that trigger in the editor.
  • %1 to %9 in the pattern capture text. A capture at the end of the pattern takes the rest of the line.
  • %0 in the action is the whole line.
  • A regex trigger's groups fill %1, %2 and so on.

List and delete

  • #trigger lists your triggers, each with a short id.
  • #untrigger {name|pattern|id} deletes one. #unaction also works.

Use the editor instead

Choose Script › Triggers, or open the Inspector with ⌘⇧I. Each trigger has an on/off switch, Edit and delete. Patterns and actions open in a large multi-line editor. Export Profile… and Import… are at the bottom of the panel.

Examples

#trigger {You are hungry.} {eat bread}
#trigger {You are thirsty.} {drink water}
#trigger {HP: %1} {#var {hp} {%1}}                store the rest of the line in $hp
#trigger {%1 tells you '%2'} {#var {speaker} {%1}}
#trigger {You hit %1} {#var {target} {%1}}
#trigger {HP: %1} {#showme hp is %1}              local text, not sent
#trigger {tells you} {reply %0}
#action {You are hungry.} {eat bread}             same as #trigger
#trigger                                          list triggers
#untrigger {You are hungry.}                      delete one

Safety limits

These limits keep a bad trigger, or text from another player, from taking over:

  • Captured text is treated as plain words. ;, {, }, line breaks and a leading # are removed, so nobody can slip extra commands into your triggers.
  • Triggers can't change your aliases, triggers, buttons, gags, highlights or chat setup. They can't load files, and they can't run map commands that change or save map data.
  • One incoming line sends at most 10 trigger commands, and at most 20 trigger commands go out per second. Past that, one warning prints. Click the warning to open the trigger.
  • Only the first 4,096 characters of a line are matched.

When you import a backup, profile or TinTin script that has triggers that send commands, Veilrunner asks first. You choose Import, Import Disabled (they come in turned off) or Cancel.

See also: Highlights & gags · Variables & lists

Still stuck? Email [email protected] with your Veilrunner version (Veilrunner › About Veilrunner), your macOS version and the MUD you were connected to, or report a bug.