Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Other_text_colour

Other_text_colour

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


Posted by Rene   (46 posts)  Bio
Date Wed 03 Jan 2018 01:40 AM (UTC)

Amended on Wed 03 Jan 2018 01:41 AM (UTC) by Rene

Message
I am trying to set a trigger to colour the text in a colour different than a custom colour. It seems the way to do this is with SetTriggerOption, yet it is not working.
Here is the lines in the code:

	AddTrigger("Name", "Rene", "", trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.KeepEvaluating + trigger_flag.IgnoreCase, -1, 0, "", "")
	--Set to repeat on same line
	SetTriggerOption ("Name", "repeat", "y")
	IfErrorCode = SetTriggerOption ("Name", "other_text_colour", "magenta")

However it returns an error, 30026, which the site says is out or range, why is it not working?
Thanks.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 03 Jan 2018 06:05 AM (UTC)
Message
Two things here.

First, the documentation for SetTriggerOption is wrong. The option "other_text_colour" is supposed to be a number, not a string. Thus you should use ColourNameToRGB to convert the string "magenta" to its appropriate colour code.

This documentation will be updated in the next release.

For example:


IfErrorCode = SetTriggerOption ("Name", "other_text_colour", ColourNameToRGB "magenta")





Second, this option is not for colour matching, it is for setting the matching text to some colour. You want option "match_style". See http://www.gammon.com.au/forum/?id=4873 for more information about that.

However the style only matches ANSI colours. The field for matching is only 4 bits for foreground and 4 bits for background, so you can only match the following colours:


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





To solve your problem you need to match (regardless of colour) and then test the colour of the matching text. See the post http://www.gammon.com.au/forum/?id=7818 for how to get the colour of a particular part of the line you matched on. You can then disregard any lines that don't match that colour.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rene   (46 posts)  Bio
Date Reply #2 on Wed 03 Jan 2018 10:35 PM (UTC)

Amended on Wed 03 Jan 2018 10:36 PM (UTC) by Rene

Message
Thanks, I meant changing the text colour like your first response, unsure why you understood me differently.
Either way, it didn't work for me, yet I found if I do this:

SetTriggerOption( "Name", "custom_colour", tostring(17))
IfErrorCode = SetTriggerOption ("Name", "other_text_colour", ColourNameToRGB "magenta")


Then it worked, unsure why that is.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 04 Jan 2018 05:13 AM (UTC)
Message
Sorry for the misunderstanding. I thought you were asking about matching a colour, don't quite know why. :)

You need to set the colour type to "other" like you did (I don't think the tostring is neccessary):


SetTriggerOption( "Name", "custom_colour", 17)


As documented, that is "use other colour":

Quote:

"custom_colour": 0=no change, 1 - 16, 17=other


Then your second line defines what the other colour is.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


14,118 views.

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

Go to topic:           Search the forum


[Go to top] top

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