Trigger reacting to itself / looping

Posted by Natasha on Thu 31 Jan 2019 12:16 AM — 7 posts, 21,414 views.

#0
I have a problem with my trigger.
Basically, when I try to cast a spell, it has a chance to fail (resulting in "You lost your concentration!" message in output). I want the trigger to re-cast the spell until it succeeds.
Currently, it reacts to the message and also casts the spell without a problem.
The problem is that it doesn`t react to the message once it has been fired (or rather the message this trigger caused).
Here is the trigger:

<triggers>
  <trigger
   enabled="y"
   group="Casting"
   keep_evaluating="y"
   match="You lost your concentration!"
   name="spellAutoRetry"
   send_to="12"
   sequence="100"
  >
    <send>
       activeSpell = GetVariable('activeSpell')
       Send("cast '" .. activeSpell .. "'")   
    </send>
  </trigger>
</triggers>

EDIT:
I have "activeSpell" variable declared in MUSHClient, it holds the name of the spell I want to re-cast
Amended on Thu 31 Jan 2019 12:22 AM by Natasha
USA Global Moderator #1
The trigger doesn't cause messages. The trigger sends a command to the server. Whatever happens after that is a whole new sequence of events. If your trigger isn't matching what comes back, then either the pattern has changed or the trigger or trigger group has been disabled by something else. Can you show a full copy-paste from the game of you casting a spell, the trigger catching the concentration failure, recasting, and then failing to catch the next concentration failure? That would help rule out whether the pattern needs to be changed.
Amended on Thu 31 Jan 2019 05:09 PM by Fiendish
#2
Thanks for your swift reply.
I also disabled all timers, alliases and triggers to rule out the "interference" problem.

Here is the output:

[AFK] 741H 3010M 1083V (100) 0TNL>
cast 'create food'
You lost your concentration!
cast 'create food'

[AFK] 741H 3007M 1083V (100) 0TNL>You lost your concentration!

[AFK] 741H 3004M 1083V (100) 0TNL>
Amended on Thu 31 Jan 2019 07:34 PM by Natasha
Australia Forum Administrator #3
You are matching on "You lost your concentration!"

This won't match on:


[AFK] 741H 3007M 1083V (100) 0TNL>You lost your concentration!


There is stuff in front of "You".

You could change the trigger to match on:


*You lost your concentration!
Amended on Thu 31 Jan 2019 08:08 PM by Nick Gammon
USA Global Moderator #4
IMO instead of changing the match pattern you should change your prompt line to end in a carriage return. Triggers are much safer when you can reliably choose to only match at the start of a line. It makes misfires much less likely. If you change your match pattern to start with * then anyone can screw with your trigger just by talking.
Amended on Thu 31 Jan 2019 08:49 PM by Fiendish
#5
Thanks a lot - it works (It was the prompt).
Sorry for bothering you with such a thing.
Australia Forum Administrator #6
Fiendish has an excellent point. If the MUD lets people emote things, someone could emote. "You lost your concentration!" which would make your trigger fire.