Temporary Triggers

Posted by Gore on Wed 04 Feb 2004 12:48 PM — 12 posts, 40,315 views.

#0
Hey what's up, was wondering if someone could tell me the command to make a temporary trigger via alias.. or script? I can't seem to find it when I search the forum/help files for mushclient

Thank you
Australia Forum Administrator #1
See this page:

http://www.gammon.com.au/scripts/doc.php?function=AddTrigger

Add (or OR) 16384 to the trigger flags when you create it.

However do you really want a temporary trigger? A temporary trigger is one that is not written to the world file.

For a trigger that only works for a while you may really want to either disable or delete it. See:

http://www.gammon.com.au/scripts/doc.php?function=EnableTrigger

and

http://www.gammon.com.au/scripts/doc.php?function=DeleteTrigger

#2
Yeah, in ZMud, I used it as a temporary trigger.. in MUSHClient, I'm having a hard time having Multiple triggers of the same pattern that do different things. I read the help file on sequencing, and I changed the sequence on of one of my triggers to 99 and left the other with the same pattern at 100, but then the one that I changed didn't work anymore. Any ideas?
#3
Err, here's an example of what I mean.. with the sequencing..

<aliases>
<alias
script="selfish_off"
match="gen"
enabled="y"
group="anti_theft"
sequence="100"
>
</alias>
<alias
script="selfish_on"
match="self"
enabled="y"
group="anti_theft"
sequence="100"
>
</alias>
</aliases>
<triggers>
<trigger
custom_colour="3"
enabled="y"
match="You have recovered equilibrium."
script="auto_bash"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>stand</send>
</trigger>
<trigger
custom_colour="3"
group="anti_theft"
match="You have recovered equilibrium."
name="generosity_eq"
script="generosity_on_eq"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>stand</send>
</trigger>
<trigger
custom_colour="6"
enabled="y"
group="anti_theft"
match="^(.*?)h\, (.*?)m ex\-A feeling of generosity spreads throughout you\.$"
name="generosity_trigger"
regexp="y"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>selfishness</send>
</trigger>
</triggers>

Sub Selfish_on (a,b,wildcard)
Selfishness = "1"
World.Send "selfishness"
World.EnableTrigger "generosity_trigger", TRUE
End Sub

Sub Selfish_off (a,b,wildcard)
Selfishness = "0"
World.Send "generosity"
World.EnableTrigger "generosity_trigger", FALSE
End Sub

Sub Generosity (a,b,wildcard)
World.EnableTrigger "generosity_eq", TRUE
End Sub

Sub Generosity_on_eq (a,b,wildcard)
World.Send "selfishness"
World.EnableTrigger "generosity_eq", FALSE
End Sub

Now, I've got two triggers with the pattern "You have recovered equilibrium", but the trigger that calls the subroutine "generosity_on_eq" doesn't fire..

If you could help me with this, thank you :D
Australia Forum Administrator #4
If you want two triggers to match then you must check "keep evaluating" in the trigger dialog, otherwise MUSHclient stops when it first gets a match. This is deliberate, so you can put a "stopper" trigger in with an earlier sequence number.

If you have "keep evaluating" checked (in both) then the sequence won't matter.
#5
Alright, can you explain any strongpoints to a "stopper" trigger and sequencing?
USA #6
Hmm.. Hard to give an example, but say you are coloring text from a channel called gossip. However, you also want to color anything from 'Fred' a different color, so they stand out. You might do:

<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   group="channels"
   match="^([gossip]) Fred:(.*)"
   regexp="y"
   sequence="5"
   other_text_colour="orange"
   other_back_colour="black"
  >
  </trigger>
  <trigger
   custom_colour="17"
   enabled="y"
   group="channels"
   keep_evaluating="y"
   match="^([gossip])(.*)"
   regexp="y"
   sequence="6"
   other_text_colour="blue"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Now, as to why. Triggers don't fire in any specific order, though they may execute in more or less the order created. It isn't predictable. So, lets say all of the ones above where set to sequence 100 and all used 'keep_evaluating="y"'. Lets call them 1 and 2 to make it easier. You could have any one of the following happen:

#1 is tested, it matches Fred, turns the line orange.
#2 matches and changes the color again to blue.

#2 matches, line becomes blue
#1 matches, line turns orange

Obviously only one of these works. By leaving the first trigger as the default setting of off of 'keep_evaluating', the first instance above would stop the line from instead turning blue. By changing the sequence so #1 will *always* happen first, you eliminate the cases where it may match on #2 first, then #1.

But this is not a major issue. Lets say you had a third trigger that turned all instances with the word 'poison' in them green or something.

<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   keep_evaluating="y"
   match="poison"
   regexp="y"
   sequence="7"
   other_text_colour="green"
   other_back_colour="black"
  >
  </trigger>
</triggers>

In this case if it matches *before* either the Fred trigger or the main channel trigger, then the word poison would never be colored. As soon as the Fred or main trigger hit, everything on the line would instantly turn orange or blue, including the word 'poison'. Now sequences become critical. Both of the prior triggers *must* allow the text to pass through 'keep_evaluating="y"', but the main gossip trigger *must* happen first. Why?

Fred matches (sequence 5) - turns orange.
Main matches (sequence 6) - turns blue.
Poison matches (sequence 7) - colors the word poison.

I this case while it would be nice to use a 'stopper', like the original Fred trigger above. Now you need the new poison trigger to work with both. Thus you have to change the sequences to work like:

Main matches (sequence 5) - turns blue.
Fred matches (sequence 6) - turns orange.
Poison matches (sequence 7) - colors the word poison.

It all depends on what you actually need to do. There are times when you want a specific line to stop any further triggers, scripting, coloring, etc. from happening once detected. Other times the specific order they happen in is critical. Occationally things need to both happen in a specific order *and* have one of them stop anything else happening. I don't often use triggers that don't have keep evaluating set on, with the exception of maybe one case I actually need it. Most of the time, simply forcing things to happen in the proper order solves most issues.
#7
Alright, so can you have keep evaluating on and also have them sequence? Also, Can you have like, Trigger 1 sequenced to 1, then Trigger 2 sequenced to 50?
USA #8
Yes. I am not sure what the limit on sequences are, but I have ones ranging from 0 to 700. In some case I am even using the number just to place associated triggers in the same place in the list, since it will sort them by sequence. I kind of wish it did that by group first though. The only thing that matters with sequence is what order you want them to execute in, not the actual numbers.
Australia Forum Administrator #9
Stopper triggers? Well you might be collecting a WHO list, for instance with a trigger that matches everything (*) but need another trigger first to detect the end of the list (eg. * players connected).

Thus the stopper trigger should fire first.

As for sequence numbers, they can be in the range 0 to 10,000.

Australia Forum Administrator #10
Quote:

Alright, so can you have keep evaluating on and also have them sequence?


Yes, that is one of the reasons for sequencing, so they are evaluated in the *correct* sequence.
#11
Nice, thanks a lot Nick :D