Difference between revisions of "Help/Trigger"

From DikuMUD Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
= Trigger =
 
= Trigger =
  
If you want to do whatever the beastly Fido tells you to do:
+
If you're playing DikuMUD with the web-client there is built-in support for
 +
triggers. A trigger is useful for sending commands to the MUD when certain
 +
text appears on your screen.
  
  {trigger obey /^the Beastly Fido tells you '(.+?)'/ $1}
+
Triggers in the web-client are based on Java Script Regular Expressions.They're
 +
super powerful but they can also be a bit tricky to use. Best with a few examples:
  
Or maybe you'd like to
+
Usage:
 +
  trigger <regexp> command
  
   {trigger smarmy /^(@friends)\sleaves (.+?)\.$/ say I love $1. Especially when $1 leaves $2.}
+
Say for example, you want to do whatever the beastly Fido tells you to do. This
 +
command will trigger on the tell from beastly fido, will extract what the dog
 +
told you and will execute the command (the $ sign):
 +
 
 +
  {trigger obey /^the Beastly Fido tells you '(.+?)'/ $
 +
 
 +
Or if maybe, every time one of your friends leaves a room you'd like to
 +
"I love <friend>. Especially when <friend> leaves <direction>.". This is
 +
how to do it:
 +
 
 +
  {value friends papi|city guard|fido}
 +
   {trigger loveit /^(@friends)\sleaves (.+?)\.$/ say I love $1. Especially when $1 leaves $2.}
  
 
You may notice this is written with Regular Expressions. If you're not familiar or want to learn more
 
You may notice this is written with Regular Expressions. If you're not familiar or want to learn more

Revision as of 12:27, 21 September 2020

Trigger

If you're playing DikuMUD with the web-client there is built-in support for triggers. A trigger is useful for sending commands to the MUD when certain text appears on your screen.

Triggers in the web-client are based on Java Script Regular Expressions.They're super powerful but they can also be a bit tricky to use. Best with a few examples:

Usage:

 trigger <regexp> command

Say for example, you want to do whatever the beastly Fido tells you to do. This command will trigger on the tell from beastly fido, will extract what the dog told you and will execute the command (the $ sign):

 {trigger obey /^the Beastly Fido tells you '(.+?)'/ $

Or if maybe, every time one of your friends leaves a room you'd like to "I love <friend>. Especially when <friend> leaves <direction>.". This is how to do it:

 {value friends papi|city guard|fido}
 {trigger loveit /^(@friends)\sleaves (.+?)\.$/ say I love $1. Especially when $1 leaves $2.}

You may notice this is written with Regular Expressions. If you're not familiar or want to learn more this site RegEx Reference allows you to build triggers.

See also:

 {Help bot}
 {Help variable}
 {Help alias}