Manual:DIL Manual/addcolor()
Jump to navigation
Jump to search
addcolor()
Function (integer). Gives a player their own colour for a colour name.
addcolor(pc : unitptr, key : string, colour : string)
Adds key to the player's personal colours with the value colour. From
then on, text inside <div class='key'> (see
getcolor()) is shown to that player in this colour instead of
the game's default. The colours are saved with the player, and the color command
lists them. A player with no colour of their own for a key gets the default from
vme/etc/color.def.
Parameters
| Name | Type | Meaning |
|---|---|---|
| pc | unitptr | The player. Must be a PC. |
| key | string | The colour's name: 1 to 20 letters, digits or _.
|
| colour | string | The colour, written as in color.def: a foreground and a background, such as "cpc bn".
|
Returns
Integer: TRUE when the colour was added, FALSE when the player already
has that key. It fails, and writes a line to the zone's log, when pc is null or not
a PC, when the key is empty, too long or has other characters, or when colour is
empty.
Notes
- A key is matched by abbreviation: if the player has
clan_who,
addcolor(pc, "clan", ...)finds it and returnsFALSE. Use changecolor() to change an existing one.
- The colour isn't checked. The
colorcommand accepts a foreground of
c, an optionalp(bright) and one ofn r g y b m c w, then a background ofband one ofn r g y b m c:"cw bn"is white on black,"cpy bn"bright yellow. Stay with those.
- Personal colours only change what telnet players see. The web client gets the class name
and colours it with its own style sheet.
Example
dilbegin set_clan_col(pc : unitptr, colour : string);
var
i : integer;
code
{
if (pc.type != UNIT_ST_PC)
quit;
if (not addcolor(pc, "clan_who", colour))
i := changecolor(pc, "clan_who", colour);
sendtext(getcolor("clan_who") + "Your clan list looks like this now.</div><br/>", pc);
quit;
}
dilend
Sets a player's colour for clan_who, adding it or changing it.