This is giving me some grief.

Posted by Spetz on Tue 01 Mar 2011 08:18 PM — 4 posts, 20,579 views.

#0
I have made an autorescue trigger. My trigger works fine, but after some field testing I have run into the problem that I want to only try to rescue the person once every 5 seconds or so. This is due to my mud having lag penalties for rescue so if multiple people get attacked I end up trying to rescue each one about 5 times before I am out of lag from the first one.

I also have a trigger that automatically adds people to the variable "group". I can post it if you would like it.

Here is what I have:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="(?U)^(?!You)(.*) (attack|attacks) (strikes|strike|haven't hurt) (@!group) (?!you)(.*) (time|times), with * *."
   name="Autorescue_1"
   regexp="y"
   sequence="100"
  >
  <send>rescue %4</send>
  </trigger>
</triggers>



<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="(?U)^(?!You)(.*) attacks haven\'t hurt (@!group)\!$"
   name="autorescue_2"
   regexp="y"
   sequence="100"
  >
  <send>rescue %2</send>
  </trigger>
</triggers>



<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="^You fail to rescue (.*?) from"
   name="I_Fail_Rescue"
   regexp="y"
   sequence="100"
  >
  <send>rescue %1</send>
  </trigger>
</triggers>


Again really if my variable contains:

Mike|Fred|Jim

and Fred gets attacked I only want to send the rescue once. I considered building into the trigger a line that disabled the trigger and activated a timer for 5 seconds that would run once and re-enable the trigger. The problem with this is if another groupie gets attacked while the trigger is disabled I would not be able to get them.

Thanks for any input you could give me.
USA #1
What if you remove the name from the list, and set a timer for 5 seconds to add it back?
Australia Forum Administrator #2
Something like this will do it. You remember when you last rescued someone in a Lua table, and only do it again if 5 seconds have elapsed:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="(?U)^(?!You)(.*) attacks haven\'t hurt (@!group)\!$"
   name="autorescue_2"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

recent = recent or {}

local who = "%2"

if not recent [who] or (recent [who] + 5 &lt; os.time ()) then
  Send ("rescue " .. who)
  recent [who] = os.time ()
else
  ColourNote ("green", "", "Recently rescued " .. who)
end -- if

</send>
  </trigger>
</triggers>

#3
Twisol,

I did not simply remove the name because I could not figure out how to.

Nick,

Thanks a bunch this seems to work (although I have not had any testing in battle just the simulator) and I am always amazed at how simple it really is once I see it. Also thanks for the quick response.