Match starting color

Posted by MattMc on Sat 13 Nov 2004 09:08 PM — 5 posts, 21,690 views.

USA #0
Using settriggeroption, how does one match colors? All I found was other_text_colour which I thought was for highlighting the line in special ways...

I'm watching to grab a line that STARTS with red (but allows color changes along the way).

Matt
USA #1
You can see the options by setting a trigger and then copying it and looking at the names.

match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"

turn the checking on.

text_colour="8"
back_colour="9"
bold="y"
inverse="y"
italic="y"


are what are checked against.

I don't know what the scheme is for the color numbers, you'll have to set a trigger and copy/paste it to find out.

And there is another thread about the tristate-ness of the inverse, bold, italic. Basically its the first flag (to enable matching) has to be set if you want it to check, and then the flag itself is what its checked against (for a 'dont care' you wouldnt set the match_bold).

Depending on your triggers, you might want to consider using ImportXML.
USA #2
Hmm, I put in all that stuff and it didn't appear to work. It is still capturing not-bold whites and bold whites.

Here is what I got:
 
'*******************Start of new color code capturing*********************************
World.AddTrigger "ClanPKTrigger", "^("&exploded&")( )+\((.*?)\)$", "",39,-1,0, "", "FlagName"
SetTriggerOption "ClanPKTrigger", "match_back_colour", "y"
SetTriggerOption "ClanPKTrigger", "bold", "y"
SetTriggerOption "ClanPKTrigger", "match_text_colour", "y"
SetTriggerOption "ClanPKTrigger", "text_colour", "9"
SetTriggerOption "ClanPKTrigger", "back_colour", "8"
SetTriggerOption "ClanPKTrigger", "match_inverse", "y"
SetTriggerOption "ClanPKTrigger", "match_italic", "y"
SetTriggerOption "ClanPKTrigger", "match_bold", "y"
'********************End of new color code capturing**********************************


Edit: And by the way, I did try it as world.settriggeroptio n and in this later try w/o the world part. Not sure what the difference is. I also tried the numbers w/o quotes ("text_color", 9) and with quotes (above).
Amended on Sat 13 Nov 2004 09:47 PM by MattMc
USA #3
There is no difference with world or not. Except for using Execute. You can search if you want to know the reasons behind this, but its not important to know why to use it.

Check your trigger, does it get changed?
And youll be using strings.

"9" not 9.

Why exactly are you adding triggers?
Couldnt you use a variable and accomplish the same results, without the extra lines and overhead?
Australia Forum Administrator #4
There is no "match_text_colour" option documented for SetTriggerOption.

If you had tried this:


world.note world.SetTriggerOption ("ClanPKTrigger", "match_text_colour", "y")


You would have got the number 30025 displayed.


(eUnknownOption (30025) Option name not found)


Looking more closely at the source code, all of those options are stored in a single field "match_style".


/*

Trigger iMatch flag will be as follows:

  TBFS    

  T = what style to test, see below
  B = background colour, see below
  F = foreground colour, see below
  S = what style bits are wanted, see below

*/


NORMAL     0x0000   // normal text
HILITE     0x0001   // bold
UNDERLINE  0x0002   // underline
BLINK      0x0004   // italic (sent to client as blink)
INVERSE    0x0008   // need to invert it

MATCH_TEXT      0x0080  // match on text colour?
MATCH_BACK      0x0800  // match on background colour?
MATCH_HILITE    0x1000  // match on bold bit?
MATCH_UNDERLINE 0x2000  // match on underline?
MATCH_BLINK     0x4000  // match on blink?
MATCH_INVERSE   0x8000  // match on inverse?


Colours


BLACK = 0
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
MAGENTA = 5
CYAN = 6
WHITE = 7


The simple way of using this is to set up an example trigger and then do something like this:


/world.note GetTriggerOption ("ClanPKTrigger", "match_style")


This will show you the number to use in subsequent scripts.

However to explain exactly how it works, we'll set up an example and work through it.

I've set up a trigger with the "match" line reading:


Match: Red on Green - [X] Bold - [X] Italic - [ ] Inverse


In other words, match on red text on green background, bold must be set, italic must be set, inverse must not be set.

Typing this line:


/world.note GetTriggerOption ("ClanPKTrigger", "match_style")


gives:


55957


However it is easier to see the results in hex:


/world.note hex (GetTriggerOption ("ClanPKTrigger", "match_style"))


which gives:


DA95


Breaking this number up into 4 lots of 4 bits, we get this:

  • D - what styles to test (MATCH_BLINK + MATCH_HILITE + MATCH_INVERSE) (8 + 4 + 1 = 13 which is "D" in hex)

    Note, in this context "blink" means italic and "hilite" means bold.
  • A - background match (MATCH_BACK + GREEN) (8 + 2 = 10 which is "A" in hex)
  • 9 - foreground match (MATCH_TEXT + RED) (8 + 1 = 9)
  • 5 - Wanted style (BLINK + HILITE) (4 + 1 = 5)


In the above we are *testing* blink+hilite+inverse (D) however we want to get the result 5, which would only happen if inverse was *off*.




To sum that up, you could do this to achieve the settings I have above:


/world.SetTriggerOption "ClanPKTrigger", "match_style", 55957


Having explained all that, you can see that doing an example and working off that would be easier. Also you could do what Flannel suggested and use ImportXML instead.