Also in this section: Aliases | Variables | Examples and importable scripts
WARNING! TOO MANY TRIGGERS WILL SLOW DOWN YOUR CLIENT
As an additional warning, many muds do not like players using triggers. RotJ will allow you to have triggers, but you may not use them to bot. Read the game help files and ask questions if you feel you might break this rule.
A trigger consists of two main
parts, the pattern, and the command line.
The pattern is where you put
what the trigger will run on. It is usually what text will be received
from the mud. When the correct line of text arrives, if the trigger is
enabled, the command line will be run.
The pattern can have wildcards in it, for when the line of text won't always look exactly the same, but some parts will always be. Like for instance:
"You feel your skill in Defensive fighting improving."
"You feel your skill in Deflect improving."
You could then create a trigger that runs on:
"You feel your skill in * improving."
This trigger will then run for any of your skill increases. If you wish to use the name of the skill that increased for something, you have to put the 'anything' wildcard * in parenthesys like this:
"You feel your skill in (*) improving."
Then you could have a Commands bit like:
"say I just got better at %1"
The only sensible way to create a new trigger is to click on triggers, click new, and enter the information.
Note: zMUD has trouble evaluating text received that contains normal brackets ( ). You need to specify with the Do-Not-Parse-This character, which is the tilde ~
For example:
Pattern: ~(Blue Aura~)
Command: #cw blue
This trigger is exactly as you would find it in my client. It makes all the Blue aura mobs have their (Blue Aura) displayed in blue, and I have a similar trigger for (Red Aura) mobs. If you use #color to change the color, the whole line would be changed. #cw only changes the matched pattern. So in this case, the rest of the mob's name would still appear as it always did.
Another example:
Pattern: ...*glows with the power of the force!
Command: #color 15
What this does is change the whole line to White (which is what my color number 15 is set to), regardless of what was in the * area. I use a * because it could say "He glows" or "She glows" or even "It glows". But I don't want to remember the value, so there is no parenthesys.
To have a plain trigger, like
for hunger, the pattern will be :
You are hungry.
The command line will then
be your usual procedure of eating food:
get ration net ; eat ration
When you start having a lot
of triggers, it is a good idea to divide them into Classes.
This has two benefits: All
related triggers will be in a folder if you want to go
looking for one, and you can deactivate or activate the entire class with
either a click on the appropriate button (which you'll have to make yourself,
hehe) or a command in the main window:
#T+ <classname> or #T- <classname>. In 7.05 you can also go into
Settings, click the class and deselect "Enabled" in the Options pane.
Where this gets lovely, is
that you can have triggers deactivate/activate other triggers. One of the
triggers I do this alot with, is for assisting mobs. I have a trigger class
WFD (wait for death) and a class Assisters.
WFD only has one trigger in
it. When a mob dies, check if the variable "assists" is greater than 0.
If it is, "assist" is sent to the mud. If assists is 0, WFD deactivates
itself.
The two classes work like this:
A mob assists another -> add 1 to assists -> WFD
is activated -> mob dies -> check assists (will be 1, if only one mob assisted)
-> assist again -> reduce assists by 1 ---> mob dies -> check assists (probably
0 now) -> shut WFD down
Granted, you will get assist
spam if mobs assist and you leave battle before it dies, but as yet I have
not thought of a solution for this. I only have a partial solution for
it.
#gag is a VERY cool command.
It removes the line of text from the main window.
So having a #gag trigger on
"But nobody is fighting " would be a good idea
I have a gag trigger on <AUCTION
: *> wtb *
:p
(Pattern: But nobody is fighting
Command: #gag)
If you have problems with triggers running because somebody said the line of text on a public channel, you could modify your trigger to specifically only run when the line of text was on it's own line. (Which is the normal situation)
To do this, you simply have to place a ^ at the start of the Pattern of that trigger. So let's say you are tired of being annoyed by people saying the sanc run-out line on comlink, your trigger probably looked like this:
Pattern: The white aura around your body fades.
And then whatever commands you had for it.
The problem is then the trigger WILL fire on the line of text:
<COMLINK: Idiot> heh, it just said The white aura around your body fades. hahaha
But if you place the ^ in front of the pattern, the trigger will now ONLY fire on the line of text:
The white aura around your body fades.
BUT also on the line (for example a gecho) :
The white aura around your body fades. Hope I didn't trigger anybody :-)
To put an identical limit on the pattern, except on the end, use a $ at the end of the pattern. I will give an example of the trigger I use for my pcom timer. Included in this example is how to use multiple possibilities for a trigger pattern. (This is how I reduced the Damage Substitution trigger script from 164 triggers down to 4)
Pattern: ^<Private %d: (%w)> {when|till}$
This means that the trigger will only fire when <Private starts the line and when or till ends the line. The %d means I don't care which pcom I'm on, but it has to be a number. The (%w) means it has to be one word (so people with charmies with multiple-word names don't spam me) and the () also indicates I want zmud to temporarily store that name in a variable. (This is how I work my auto-ignore trigger script for my timer). Then the {when|till} indicates that either when or till can end the line. Do note that you cannot use wildcards (like %w or %d or *) inside the { | } part.
So if somebody said 'when when' on the pcom, it wouldn't do anything, because the line ends past the designated-by-me first 'when'.
Also in this section: Aliases | Variables | Examples and importable scripts