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

MUSHclient scripting

Description of MUSHclient world function: world.MapColour

Name MapColour
Type Method
Summary Changes the colour mapping - the way colours are displayed
Prototype void MapColour(long Original, long Replacement);

View list of data type meanings


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.

Note: Available in version 3.54 onwards.

VBscript example
MapColour ColourNameToRGB ("red"), ColourNameToRGB ("green")
Jscript example
MapColour (ColourNameToRGB ("red"), ColourNameToRGB ("green"))
Lua example
MapColour (ColourNameToRGB ("red"), ColourNameToRGB ("green"))
Returns None.
Introduced in version 3.54

See also ...

Function Description
ColourNameToRGB Converts a named colour to a RGB colour code.
GetMapColour Returns the mapping for how a particular colour will be displayed
MapColourList Returns an array of all the mapped colours
Redraw Schedules a redraw for all windows for this world
RGBColourToName Converts an RGB colour code to its equivalent name

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.

Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes

Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes

View all functions


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.


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 FutureQuest]