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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  How to get the exact colour codes sent in by the MUD?

How to get the exact colour codes sent in by the MUD?

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


Posted by VBMeireles   Brazil  (47 posts)  [Biography] bio
Date Tue 22 Mar 2016 05:11 PM (UTC)

Amended on Tue 22 Mar 2016 05:14 PM (UTC) by VBMeireles

Message
I play a MUD which supports the customization of its colours through "XTERM" colour codes.

This is an excerpt of this MUD's "help colour":

As your client supports 256 colours, you may also specify a three digit 'rgb' sequence, with each digit representing a colour intensity from 0 to 5 (eg '533' for pink, '530 for orange, etc).

I've customized my colours to my taste (they were too bright): http://imgur.com/a/AixnZ

My problem, however, is that I have some script lines which "replace" some lines sent by the MUD and I haven't been able to guess which colour codes the MUD is using exactly.

For example, when I replace a line that contains a word that is in "aqua" (at least to my eyes), using "aqua" as the foreground option in ColourNote() gives me a color that is slightly off (a bit brighter) than the "aqua" actually used by the MUD.

It can easily be seen in the second picture that the tone of aqua (the MUD's aqua) used in "a sapphire ring of power" is different than the aqua (my ColourNote("aqua")) used in "A rare relic".

Is there a way for me to retrieve the actual code sent by the MUD for his "aqua" in order for me to replicate it exactly?

Thank you.

EDIT: The tone of "aqua" sent by the MUD was setup through the following command "colour rare 144" as explained in its "help colour". So I need to figure out what will make MUSHclient give me the same colour as the MUD gives me from this "144" colour code.

Vinícius
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #1 on Tue 22 Mar 2016 08:43 PM (UTC)

Amended on Tue 22 Mar 2016 10:38 PM (UTC) by Wuggly

Message
Made you a quick plugin to read the styles on each line to get the color code.

Start reading them by typing "read styles on" and stop it with "read styles off"

Template:saveplugin=Style_Reader To save and install the Style_Reader plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Style_Reader.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Style_Reader.xml (which you just saved in step 3) as a plugin
  7. Click "Close"


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Style_Reader"
   author="Fumino"
   id="0e24a1ea965f38cf243e5135"
   language="Lua"
   purpose="Get the styles of each line"
   date_written="2016-03-22 00:49:31"
   requires="4.51"
   version="1.0"
   >
<description trim="y">

Style runs
  
</description>

</plugin>

<triggers>

  <trigger
   enabled="n"
   keep_evaluating="y"
   match="^(.+)$"
   regexp="y"
   name="read_lines"
   script="check_lines"
   sequence="100"
  >
  </trigger>

</triggers>

<aliases>

  <alias
   match="^read styles (on|off)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
   if "%1" == "on" then
    ColourNote ("silver", "", "Read Styles: ", "green", "", "Enabled")
    EnableTrigger ("read_lines", true)
   else
    EnableTrigger ("read_lines", false)
    ColourNote ("silver", "", "Read Styles: ", "red", "", "Disabled")
   end -- if
  </send>
  </alias>

</aliases>

<script>
 <![CDATA[
    require "getstyle"
    require "tprint"

    function check_lines (name, line, wildcards, styles)
	tprint (styles)
    end -- function check_lines
]]>
</script>

</muclient>


You'll see something like this for every line when it's enabled.


1:
  "textcolour"=12632256
  "backcolour"=0
  "length"=1
  "style"=0
  "text"="blah blah blah"


Take note of the textcolour number and add that into your ColourNote.

ie:

ColourNote (RGBColourToName "12632256", "", "rare")


EDIT: Fancied up the plugin a bit.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #2 on Tue 22 Mar 2016 08:44 PM (UTC)

Amended on Tue 22 Mar 2016 08:46 PM (UTC) by Fiendish

Message
Quote:
As your client supports 256 colours, you may also specify a three digit 'rgb' sequence, with each digit representing a colour intensity from 0 to 5 (eg '533' for pink, '530 for orange, etc).

That only lets you choose 216 colors. I assume some colors are considered off limits, then? Maybe the really dark hard to see ones?

Quote:
Is there a way for me to retrieve the actual code sent by the MUD

Yes. Two ways.

If your trigger is in a plugin, and it sends to a Lua script function (this is what Wuggly's example is doing), the function will accept 4 input arguments, like so:
function my_trigger (name, line, wildcards, styles)

end -- function my_trigger

That fourth argument, styles, contains a Lua table of something called style runs.
A style run is a Lua table containing the text, number of characters, foreground color, background color, and bold/italic/underline for every section of the line where the style changes. The foreground/background color fields will give you exactly what you want.

If your trigger is not in a plugin, or does not send to a Lua script function, you can have it "Send to Script (after omit)" and then when processing the trigger it will populate a variable called TriggerStyleRuns for you that contains the same information as above.

For more information read: http://www.mushclient.com/forum/?id=7818 and http://www.mushclient.com/forum/?id=8034

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,989 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 22 Mar 2016 09:02 PM (UTC)
Message
Also see http://www.gammon.com.au/forum/bbshowpost.php?id=7761&page=4 (and other pages of that thread).

There are two colour models you can use for the 256-colour wheel.

Also see the script function: utils.colourcube

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by VBMeireles   Brazil  (47 posts)  [Biography] bio
Date Reply #4 on Tue 22 Mar 2016 11:34 PM (UTC)
Message
I got 14145375 out of a column's style.textcolour, however trying to ColourNote(14145375, "black", "something") results in the default Note() colour.

What am I doing wrong?

Side question: Would anybody care to explain why it only works if I "send to script (after omit)"? Are the different "send to" options detailedly documented anywhere?

Vinícius
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Wed 23 Mar 2016 12:09 AM (UTC)

Amended on Wed 23 Mar 2016 12:10 AM (UTC) by Fiendish

Message
Try
ColourNote(RGBColourToName(14145375), "black", "something")


VBMeireles said:

Side question: Would anybody care to explain why it only works if I "send to script (after omit)"?

Because you're either not in a plugin or you're not using Lua script body functions, and because that's just how MUSHclient is programmed to work.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,989 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Wed 23 Mar 2016 04:05 AM (UTC)
Message
VBMeireles said:

Are the different \"send to\" options detailedly documented anywhere?


http://www.gammon.com.au/scripts/doc.php?dialog=IDD_EDIT_TRIGGER

You see the same stuff if you click the Help button when editing a trigger.

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


19,811 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]