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

Posted by VBMeireles on Tue 22 Mar 2016 05:11 PM — 7 posts, 31,624 views.

Brazil #0
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.
Amended on Tue 22 Mar 2016 05:14 PM by VBMeireles
USA #1
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 the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as Style_Reader.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  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"
  8. Save your world file, so that the plugin loads next time you open it.


<?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.
Amended on Tue 22 Mar 2016 10:38 PM by Wuggly
USA Global Moderator #2
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
Amended on Tue 22 Mar 2016 08:46 PM by Fiendish
Australia Forum Administrator #3
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
Brazil #4
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?
USA Global Moderator #5
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.
Amended on Wed 23 Mar 2016 12:10 AM by Fiendish
Australia Forum Administrator #6
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.