[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Match starting color

Match starting color

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by MattMc   USA  (54 posts)  [Biography] bio
Date Sat 13 Nov 2004 09:08 PM (UTC)
Message
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
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Sat 13 Nov 2004 09:29 PM (UTC)
Message
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.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by MattMc   USA  (54 posts)  [Biography] bio
Date Reply #2 on Sat 13 Nov 2004 09:46 PM (UTC)

Amended on Sat 13 Nov 2004 09:47 PM (UTC) by MattMc

Message
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).
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Sat 13 Nov 2004 10:19 PM (UTC)
Message
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?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sat 13 Nov 2004 11:51 PM (UTC)

Amended on Sun 14 Nov 2004 12:06 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


15,147 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]