Help with syntax

Posted by DanaLea73 on Sat 11 Jun 2011 06:47 PM — 5 posts, 20,362 views.

USA #0
I'm using Nick's code from here http://www.gammon.com.au/forum/?id=8847 and modifying it for my own.. He's got lines like this in his code..

k = { range = "+32 to +41", colour = "darkmagenta", },

but the colors I want to use are in RGB format, can I change it to this?

k = { range = "+32 to +41", colour = 255,255,255 },



-- also --

I want to change the message the mud gives me completely, from:
MobName would crush you like a bug!
to:
MobName is 21 - 32 levels higher then you.
with a specific color, in this case, "255,192,0".

It won't let me post all the code, says this message is too long.

This is a work in progress.. but I don't know where to find the info I need. The Lua site to too much information, and if it's here I can't find it.

USA Global Moderator #1
you want to use something like (this example is blue)

k = { range = "+32 to +41", colour = RGBColourToName(0xFF0000) }

where the hexadecimal value (indicated by the leading 0x) is in this case 255 BLUE (FF), 0 GREEN (00), 0 RED (00) in that order. So whatever color values you want between 0 and 255, convert those numbers to hex and then lump them together in BGR order.
Amended on Sat 11 Jun 2011 06:59 PM by Fiendish
USA #2
that's easy enough, there are many converters on the web to change the RGB to hexadecimal. (for that matter, I could have found a converter for the names..hmm)

how about subbing my text for the mud output?
Amended on Sun 12 Jun 2011 12:35 AM by DanaLea73
USA Global Moderator #3
substitution is typically done by omitting from output and then doing a colournote
Australia Forum Administrator #4
DanaLea73 said:

He's got lines like this in his code..

k = { range = "+32 to +41", colour = "darkmagenta", },

but the colors I want to use are in RGB format, can I change it to this?

k = { range = "+32 to +41", colour = 255,255,255 },



The simplest change is to use the "HTML" colours which can be used where colour names are used. For example:


k = { range = "+32 to +41",     colour = "#A1B2FF", },


Where in this case A1 is the red component, B2 is the green component and FF is the blue component. The "#" is what distinguishes it from a name lookup.

If you want to see all the inbuilt colour names and what their codes are (apart from using the colour picker), type this in the scripting Immediate window:


Debug "colours"


That also shows the associated colour in the output window.