Manual:DIL Manual/changecolor()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:04, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

changecolor()

Function (integer). Changes one of a player's own colours.

changecolor(pc : unitptr, key : string, colour : string)

Gives the player's colour key the new value colour. It only changes a colour the player already has (from the color command or addcolor()); it doesn't add one.

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 new colour, such as "cpc bn" (see addcolor()).

Returns

Integer: TRUE when the colour was changed, FALSE when the player has no such 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: changecolor(pc, "cl", ...) changes the
 player's first key that begins with cl.
  • The colour isn't checked; see addcolor() for the values the
 color command accepts.
  • Personal colours only change what telnet players see.

Example

dilbegin clan_col_cmd(arg : string);
var
   i : integer;
code
{
   if (arg == "")
   {
      sendtext("Which colour? For example: clancolor cpc bn<br/>", self);
      quit;
   }

   i := changecolor(self, "clan_who", arg);
   if (i == FALSE)
      i := addcolor(self, "clan_who", arg);

   sendtext(getcolor("clan_who") + "Like this?</div><br/>", self);
   quit;
}
dilend

A player command clancolor <colour> that changes the player's clan_who colour, or adds it the first time.

See also