Hi, i'm trying to make a trigger that excludes certain words
An example of the line it is in response to: A Sel'juk murlock's slash *** DEVASTATES *** Dvick!
This trigger is for tanking and auto rescuing players that are attacked in the middle of battle primarily.
I first tried using perl regex: \*\*\* DEVASTATES \*\*\* (\w+)! with.. send("res " .. matches[2])
Which works, only a bit too well because there are other lines in the game that create unwanted rescues:
Dvick's slice injures a Sel'juk murlock. (a Sel) becomes the match.
Dvick's punch *** DEVASTATES *** a woodwose! (a woodwose) becomes the match.
a woodwose's claw DISMEMBERS you! (you) becomes the match
I was looking through the manual and found what looked like a solution - to exclude certain words from triggers.
so then I tried: \*\*\* DEVASTATES \*\*\* (a|an|you|A|An) (\w+)! with.. send("res " .. matches[3]) I tried [1] [2] [4] as well
although now I get mixed results where it still matches with words like (a) or (an) but wont match with just a players name like: A woodwose's claw wounds Dvick.
Any suggestion on how I can make this trigger auto rescue any players name without all these unwanted matches?
Thanks, Peko (Alter Aeon)
Auto rescue triggers
Re: Auto rescue triggers
You're not capturing the players name, therefore you'll never actually be able to access that data in 'matches'; it doesn't exist.
Try this:
Try this:
Code: Select all
^(A|An) .* slash \*\*\* DEVASTATES \*\*\* (\w+)\!$
Re: Auto rescue triggers
You show two possible lines there:
A Sel'juk murlock's slash *** DEVASTATES *** Dvick!
and
Dvick's punch *** DEVASTATES *** a woodwose!
which means that you have two possible states for the same line: one with a players name at the end and one with an npc's which also includes "a" or "an". It seems like you want to ignore the second one, so I'll make that assumption.
Try this:
^An? .+ slash \*{3} DEVASTATES \*{3} (\w+)\!$
Also, you need to learn how to use non-capturing groups. (?:pattern) uses the normal grouping process but does -not- save a back reference.
A Sel'juk murlock's slash *** DEVASTATES *** Dvick!
and
Dvick's punch *** DEVASTATES *** a woodwose!
which means that you have two possible states for the same line: one with a players name at the end and one with an npc's which also includes "a" or "an". It seems like you want to ignore the second one, so I'll make that assumption.
Try this:
^An? .+ slash \*{3} DEVASTATES \*{3} (\w+)\!$
Also, you need to learn how to use non-capturing groups. (?:pattern) uses the normal grouping process but does -not- save a back reference.
Re: Auto rescue triggers
Thanks for your help. I tried both replies and found that they worked, given the case. For some reason I could only get it to happen once.. I'm afraid there are too many variables to cover, and i'm very much a beginner. Sometimes mobs have very unusual strings. Player names however are always a single word after the "damage". Also, the only color of lines in which this trigger is needed is cyan. I went looking through the forums and manual to try and find a way to combine color and regex in a standard matching trigger, but I didn't find anything that I could understand.
If I could combine just
injures (\w+). and send("res " .. matches[2]) with some sort of color recognition, that would eliminate all the unwanted matches and keep it simple.
My second thought is if combining color and regex matches isn't easy, could I have just the <injures (\w+).> but ignore words between (injures) and (match) like a, an, the, you. Including information before the dammage seems to prevent the matching because it doesn't add up.
I'd like to learn non-capturing groups, it must make things a bit quicker. It was the first time i'd heard of it. I'm quite new to this stuff - thank you for your input and patience in further help.
If I could combine just
injures (\w+). and send("res " .. matches[2]) with some sort of color recognition, that would eliminate all the unwanted matches and keep it simple.
My second thought is if combining color and regex matches isn't easy, could I have just the <injures (\w+).> but ignore words between (injures) and (match) like a, an, the, you. Including information before the dammage seems to prevent the matching because it doesn't add up.
I'd like to learn non-capturing groups, it must make things a bit quicker. It was the first time i'd heard of it. I'm quite new to this stuff - thank you for your input and patience in further help.
Re: Auto rescue triggers
If you make it a multiline trigger with a delta of 0 then add the color condition with the color trigger option.
Re: Auto rescue triggers
Checking colors is easy, and you don't need a color chain.
http://mudlet.org/asciidoc/manual.html#isAnsiFgColor
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Auto rescue triggers
To capture Sel'nik you have to use the pattern: ([\w']+)
Re: Auto rescue triggers
Not all regex interpreters accept pattern groups inside brackets. A safer alternative is [A-Za-z']+ or just .+?Yetzederixx wrote:To capture Sel'nik you have to use the pattern: ([\w']+)
Re: Auto rescue triggers
Mudlet does, though.tsuujin wrote:Not all regex interpreters accept pattern groups inside brackets.
Re: Auto rescue triggers
Best to learn good general practices when you're first starting, rather than what's situationally acceptable at the moment.