Using Colours

Posted by Rene on Sun 19 Nov 2017 12:58 AM — 3 posts, 17,779 views.

#0
I would like to have the ability to change colours for different settings within the plugin.
For hex colours I found I can use the regex match (#[0-9a-fA-F]{6}) for it, but I also want to check for MUSHClient colour words, is there any way I can have check if the colour I entered is recognized by MUSH?

Thanks
USA Global Moderator #1
If I understand what you're asking for, ColourNameToRGB returns -1 if the name is not recognized.
https://www.mushclient.com/scripts/function.php?name=ColourNameToRGB
Australia Forum Administrator #2
Another approach is to use the global variable (table) that MUSHclient adds to the script space: colour_names

eg.


require "tprint"
tprint (colour_names)


Yields:


"midnightblue"=7346457
"indianred"=6053069
"purple"=8388736
"lightslategray"=10061943
"linen"=15134970
"dodgerblue"=16748574
"azure"=16777200

...

"hotpink"=11823615
"powderblue"=15130800
"lightsalmon"=8036607
"lightcyan"=16777184
"aquamarine"=13959039
"seashell"=15660543


Thus a simple test would be:


if colour_names [wanted_colour] then
  -- colour is OK
else
  -- colour not recognized
end -- if