world.MapColour

MUSHclient script function (Method) — introduced in version 3.54

Changes the colour mapping - the way colours are displayed

Prototype

void MapColour(long Original, long Replacement);

Data type meanings

Description

You can specify a "map" of an original colour to the colour you want displayed.

The intention here is to let you override the colours sent down by MUDs, particularly using MXP colours, which are not subject to the normal ANSI colour palette.

For example, if a MUD annoys you by using a lot of red letters, you could do this:

MapColour (ColourNameToRGB ("red"), ColourNameToRGB ("green"))

The mapping is done at the last moment, in the output window display routine. The rest of MUSHclient will continue normally as if the colours had not changed.

You can map any number of colours, within reason. Potentially there are 16,777,216 different colours (2 to the power 24) however in practice a particular MUD is likely to only use a handful.

The colour must match *exactly* or the translation will not occur.

The arguments to the function are RGB colours (that is, numbers in the range 0 to 16,777,215) however you can use the function ColourNameToRGB as shown above if you want to use colour names.

The colour number is really made up of three bytes:

Red (low-order byte), ie. 0 to 255
Green (middle byte), ie. 0 to 255 multiplied by 256
Blue (higher-order byte), ie. 0 to 255 multiplied by 65536

To find the colour of a particular piece of text in the output window (so you can know the "from" colour) you can select it (eg. double-click) and then use the Display menu -> Text Attributes.

This will show you the Text and Background RGB colours (in HTML format). You can use those colours in the function ColourNameToRGB to translate them to numbers. eg.

x = ColourNameToRGB ("#FF00FF")

You can find the current mapping of a colour with GetMapColour, and a list of all mapped colours with MapColourList.

To make the new colours take effect immediately, call Redraw. This would only be necessary if you are changing colours "on the fly". If you are just customising colours at world startup this would not be necessary.

VBscript example

MapColour ColourNameToRGB ("red"), ColourNameToRGB ("green")

Jscript example

MapColour (ColourNameToRGB ("red"), ColourNameToRGB ("green"))

Lua example

MapColour (ColourNameToRGB ("red"), ColourNameToRGB ("green"))

Return value

None.

Related topic

Colour management

See also

FunctionDescription
ColourNameToRGBConverts a named colour to a RGB colour code.
GetMapColourReturns the mapping for how a particular colour will be displayed
MapColourListReturns an array of all the mapped colours
RGBColourToNameConverts an RGB colour code to its equivalent name
RedrawSchedules a redraw for all windows for this world