|
This is giving me some grief.
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Spetz
(8 posts) bio
|
| Date |
Tue 01 Mar 2011 08:18 PM (UTC) [ quote
] |
| Message |
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. | top |
|
| Posted by |
Twisol
USA (2,229 posts) bio
|
| Date |
Reply #1 on Tue 01 Mar 2011 08:40 PM (UTC) [ quote
] |
| Message |
| What if you remove the name from the list, and set a timer for 5 seconds to add it back? |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | top |
|
| Posted by |
Nick Gammon
Australia (18,769 posts) bio
Forum Administrator |
| Date |
Reply #2 on Tue 01 Mar 2011 10:40 PM (UTC) [ quote
] |
| Message |
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 < os.time ()) then
Send ("rescue " .. who)
recent [who] = os.time ()
else
ColourNote ("green", "", "Recently rescued " .. who)
end -- if
</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Spetz
(8 posts) bio
|
| Date |
Reply #3 on Wed 02 Mar 2011 03:23 AM (UTC) [ quote
] |
| Message |
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. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,100 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )