Jehu's guide to Zmud-triggers for newbies



If you didn't know, a trigger means a part of a script that detects a certain line of text from the mud and perform certain actions.

Since this is a newbie guide, i will not explain all details, but rather help you get started.

To trigger on the line:

You are hungry.

The trigger can look like this:

Pattern: ^You are thirsty.
Commands: drink barrel

Note, the ^ means start of line.
Ok fine, the style of the trigger for drinking from the barrel is good for many normal things, however, sometimes other factors are important in the situation. Then you can set variables. Variables in scripts work like a word that you connect to a value.
Ex. #var assist 1
What you do is you have a variable, leader, and you connect the name number 1 to it. In this example it might be used for some triggers to know if you have auto assist on. When you handle the variables later you put a @ before the word, like @leader

A little note about " ~ "

Some signs like ', ( or ) for example, means things in commands in zmud.
So if you want to have them in the trigger pattern you need to put a ~ before them for the trigger to interpret them correctly like this: ~' or ~(.

Now, in some triggers there will be a word in the textline that you don't know in advance. For example if you follow a person and they group you, and you want to set that persons name as leader.

if it is one word containing letters, like a character's name your trigger can look like this: (here you can also see an example of how to use ~ before the ')
The line on the mud looks like this

You are now a member of Jehu's group.

And the trigger line will look like this:

Pattern: ^You are now a member of (%w)~'s group.' grouped


(the w means word %d is normal number)

Ok so now we want something to happen, we want the leader variable to be set.

Pattern: ^You are now a member of (%w)~'s group.
Commands: #var leader %1

What was that? Well %1 means the first paranthesis in the trigger line, and that will in this case be the name of the one grouping you - the leader.

If you want to execute several commands in a row,
on newer zmud you type them in on new lines, in older you add ; between them.

Like this:

Pattern: ^You are now a member of (%w)~'s group.
Commands: #var leader %1
#var assist 1

or for older zmud:

Pattern: ^You are now a member of (%w)~'s group.
Commands: #var leader %1;#var assist 1

Ok now we will make a trigger with a factor to check, with an "if" line.
if is used to compare variables, numbers etc to see if everything is right so you should execute a command.

Pattern: ^(%w) places 
Commands: #var placer %1
#if (@placer==@tank) {assist} {}

The second {} is for if the comparison dont match, like this:

Pattern: ^(%w) places
Commands: #var placer %1
#if (@placer==@tank) {assist} {say You are not my tank so i will not assist}

To check two factors, we do like this:
Pattern: ^(%w) places 
Commands: #var placer %1
#if (@placer==@tank & @assist==1) {assist} {say You are not my tank so i will not assist}

Ok the & means both these comparisons have to be true to make you assist.
1. It must be the leader doing the places thing.
2. The assist variable must be 1 which should bean that you want to assist the group.

Ok, now a little about aliases

Let me give you an example:

Name: food
Commands: 7sw
buy 20 bread
put all.bread bag
e7n

Here we have a simple alias that could just as well with some modification be a mudalias.

If you want to use parameters you can do like this:

Name: pp
Commands: cast 'powerword pain' %1

and to make that work you can either just type pp while fighting or for example pp hobbit to cast powerword pain on a poor hobbit.

Ok fine, now i want to show you how a couple of triggers can work together in a script.

Pattern: ^An Underground Lake
Commands: #var no_rest 1

This sets the variable no_rest to 1

Pattern: ^You feel a slight movement in the air
Commands: #if (@no_rest==0) {rest} {say I don't want to rest here}

The wind is blowing, ok lets rest, IF its not a water room, because then no_rest is set to 1

Pattern: ^You follow (%w)~'s group.
Commands: #var no_rest 0

Ok now we are moving along to other rooms, now set no_rest to 0 again.

Well thats it, maybe I'll add more things later.

/Jehu