|
tyh Beginner
Joined: 01 Feb 2004 Posts: 24 Location: United Kingdom
|
Posted: Thu Mar 17, 2005 1:26 pm
Help with a coloured trigger |
can someone write me a capture expression and explain the trigger for the following:
mob description strings appear in green on black on my screen. Mob names might be preceeded by characters and words in other colours e.g
(Gold Aura) *An old elf draped in a dull purple robe waits here patiently.
The gold aura and brackets are in yellow, the asterix might be white, red cyan or green or there may be one of each such as:
(Gold Aura) ****An old elf draped in a dull purple robe waits here patiently.
Also gold aura may be replaced with (Red Aura) in red. Finally there may be no bracketed aura string at all, and no asterixes (astrecies? asteri ?) and combinations thereof.
The text after the asterix is what I'm after and that is always in green with no unique recurring word ever appearing in it to trigger on, but it continues to the period and new line always all green. Basic colour capture trigger isnt flexible enough to grab this.. suggestions please. |
|
_________________ |
|
|
|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: Thu Mar 17, 2005 5:56 pm |
Is the text you're trying to capture the only text that comes to you in all green?
You might need 2-3 triggers to do this:
Code: |
#TR "lightGreen" {%e~[1~;32m(*){%e*|}.{%e*|}$} {do stuff} "classname" {ansi}
#TR "darkGreen" {%e~[0~;32m(*){%e*|}.{%e*|}$} {do stuff} "classname" {ansi}
#TR "unspecifiedGreen" {%e~[32m(*){%e*|}.{%e*|}$} {do stuff} "classname" {ansi}
|
If you get other text in green, then it will probably match one of these triggers also.
Now the explanation:
1 - See this URL for an understanding of how ansi works: http://www.bluesock.org/~willg/dev/ansi.html.
2 - %e is zMUD's way of indicating an escape character.
3 - The ansi trigger option tells the trigger to process raw ansi (just as if you'd checked "ansi trigger" in the trigger options page.
4 - {%e*|} makes sure that if the color is changed before the newline and either before or after the period, that the pattern will still match. But if the color changes mid-text - even if it changes back to green, you will only get the first bit that is in green.
5 - "do stuff" should be replaced with what you want to do with the text, which is stored in %1 by the trigger pattern.
Good Luck! |
|
_________________ Spartacus
rm -rf .* |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Mar 17, 2005 11:22 pm |
Since you say there is no specific or known text that would always be present in the mob desc lines you seek to capture I would suggest capturing based on surrounding lines. The output you presented looks like a modified ROM base output which would mean you will only see these lines when entering or 'look'ing a room. That would place them somewhere between 2 prompts, ussually right after an exit line (that will be consistently easy to trigger). Also items are ussually in this region of output. Seperating the 2 can be problematic, but given enough information this may be a better route. Mostly it depends on what you want to do with the captured text.
So I guess my questions are what do you want to do with it after capturing it, and what is the surrounding text? |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
dkotas Beginner
Joined: 03 Sep 2004 Posts: 23
|
Posted: Fri Mar 18, 2005 6:49 pm |
If you do not need to protect this with colour Matching you could use
~(%x Aura~) [~*]&%*Capture
If you need to protect the trigger with color I came up with this ititially
~(%x Aura~) [~*]%e[1;32m&%*Capture
but it falls down as soon as you have a green prior to the text and it stays green (game wont resend the color code)
Which leaves us with 3 triggers required to ensure you capture the text, note they are mutualy exclusive since the mud will not resend the color code so we allow for any position to send the color and as long as the color code is not changed then were all good. I went with 3 for readability it's nasty as 1 big trigger and it works fine like that.
~(%x Aura~) [~*]%e[1;32m&%*Capture
~(%x Aura~) %e[1;32m[~*]&%*Capture
%e[1;32m~(%x Aura~) [~*]&%*Capture
Now for a bit of fun
~(%x Aura~) [~*]{%e[1;32m|%e[1;31m}&%*Capture
~(%x Aura~) {%e[1;32m|%e[1;31m}[~*]&%*Capture
{%e[1;32m|%e[1;31m}~(%x Aura~) [~*]&%*Capture
These will pick up red or green as long as you don't change colors again. Means you can pick either green or red to grab the variable.
All of these triggers require you enter you appropriate color code...
Hope this helps.... |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sun Mar 20, 2005 1:27 am |
Code: |
#CLASS {Test}
#VAR yellow {%e\[1;33m}
#VAR red {%e\[1;31m}
#VAR white {%e\[1;37m}
#VAR cyan {%e\[1;36m}
#VAR green {%e\[1;32m}
#REGEX {^(?:@yellow\(Gold Aura\) |@red\(Red Aura\) )?(?:(?:@white|@red|@cyan|@green)\*){0,4}(?(?<!@green\*)@green)([^\033]+?)\.} {#NO do whatever with %1} "" {color}
#CLASS 0
|
It only matches if the text part is completely green if there are any control codes during the text and until after the period it doesn't match.
I made the trigger use variables to hold the various colour codes because
well it was much easier to construct the trigger that way.
Of course you'll have to change the colour codes to the correct ones for your display.
Also this is assuming universal green throughtout the the trigger if the asterixes green is different from the text green.
then the regex pattern might look like this
#REGEX {^(?:@yellow\(Gold Aura\) |@red\(Red Aura\) )?(?:(?:@white|@red|@cyan|@green)\*){0,4}@textgreen([^\033]+?)\.} {#NO do whatever with %1} "" {color}
where textgreen would be another variable holding the colour for the text.
If the red for the aura is different than the asterix red make a similar change. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
|
|