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 ➜ Using Colours

Using Colours

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


Posted by Rene   (46 posts)  Bio
Date Sun 19 Nov 2017 12:58 AM (UTC)
Message
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
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Sun 19 Nov 2017 03:57 AM (UTC)
Message
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

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 19 Nov 2017 04:18 AM (UTC)
Message
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

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


13,549 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.