TkTurf Triggers

TkTurf 2.1+: Triggers v1.1

The triggers dialog gives you a listing of all existing triggers and the option
to create a new trigger, change an existing one, or delete the highlighted
trigger.  Note that editing an existing trigger and changing the search string
will create a clone of the trigger with the new search (if you want to get rid
of the old one you must delete it).  This is so that similar triggers may be
cloned easily.

TkTurf uses Perl and TCL/TK style regular expressions with nine substring match
buffers.  Here is a brief (and comprehensible) explanation of what you can do
with triggers and what the basics of regular expressions are.

Regular expression syntax defines the following special characters:
	][$^?+*()|\.
If you wish to use any of those as a literal symbol, you must "escape it" by
doing this \? which would mean a real question mark, or \. which would mean a
real period.

These special symbols let you do neat things with triggers, here is a summary
of what each special symbol means:

[] can be used to delimit a set of characters, for example [a-z] would match
any lower-case letter, and [a-z0-9] would match any lower case letter or
number. To use these they must be escape UNLESS they are in parenthesis (i.e.
\[^ \] unless it is ([^ ])

^ can be combined with [] to say anything which does NOT match the pattern, for
example [^0-9] would match anything which was NOT a number, and [^ ] would
match anything which is not a space, and so on.

$ can not be used for anything special.

? means zero or one of the previous character, for example, g? would mean zero
or one letter g's

* means zero or more of the previous character, y* would mean zero or any other
number of y's.  This is most useful with something such as [^ ]* which would
mean all characters which were not spaces (i.e. any one word)

() can be used to delimit a sub pattern, sub patterns will be saved into
buffers named 1-9, in the order in which the () sets appear.  For example
"([^ ]) throws a snowball at you\." would mean save whatever word is at the
start of that sentence and put it in buffer 1.  More on this later.

| can be used inside of () to say or, so (you|me) would match "you" or "me". 
You may have as many of these as you like inside a () set.

\ indicates an escape character.  The only one you should really need to know
about is \n, which is the beginning of another line. *TkTurf allows you to set
trigger matches which extend for more than one line.* This can cause problems,
but also makes for extremely flexible triggers.

Okay, now what can you do with all this garbage?  Here are some handy examples,
the trigger is on top, the reply action on the bottom:
	([^ ]*) throws a snowball at you\.
	snowball $1
This trigger means *save the first word in the line* in buffer one, the reply
uses the saved word in buffer one to snowball the original thrower.  The
buffers can be used in this manner, by putting $1 or $2, $3, etc wherever you
want the information from any buffer.

You could also filter or bombs...
	([^ ]*) gives you (a|an) (armed grenade|bomb|stick of dynamite)
	drop $3
	glare $1
This would scan for people giving you an armed grenade, or a bomb, or a stick
of dynamite and automatically drop it, and glare at the giver, by using buffers
1 and 3, as they are named from left to right.  But how do you do something
with more than one reply in the command?  Remember that typing shift-return in
the main entry box for sending data to Turf allows you to string multiple
commands together?  Same deal in the add/edit trigger dialog, just hit
shift-return where you want the new command to start.

Back to Turf's Homepage