Difference between revisions of "Manual:DIL Manual/changecolor()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = changecolor() = | |
| + | '''Function''' (integer). Changes one of a player's own colours. | ||
| − | + | changecolor(pc : unitptr, key : string, colour : string) | |
| − | + | Gives the player's colour <code>key</code> the new value <code>colour</code>. It only changes a | |
| − | + | colour the player already has (from the <code>color</code> command or | |
| − | + | [[Manual:DIL Manual/addcolor()|addcolor()]]); it doesn't add one. | |
| − | |||
| − | |||
| − | |||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | < | + | ! Name !! Type !! Meaning |
| + | |- | ||
| + | | pc || unitptr || The player. Must be a PC. | ||
| + | |- | ||
| + | | key || string || The colour's name: 1 to 20 letters, digits or <code>_</code>. | ||
| + | |- | ||
| + | | colour || string || The new colour, such as <code>"cpc bn"</code> (see [[Manual:DIL Manual/addcolor()|addcolor()]]). | ||
| + | |} | ||
| − | + | == Returns == | |
| + | Integer: <code>TRUE</code> when the colour was changed, <code>FALSE</code> when the player has | ||
| + | no such key. It fails, and writes a line to the zone's log, when <code>pc</code> is null or not | ||
| + | a PC, when the key is empty, too long or has other characters, or when <code>colour</code> is | ||
| + | empty. | ||
| − | + | == Notes == | |
| − | + | * A key is matched by abbreviation: <code>changecolor(pc, "cl", ...)</code> changes the | |
| − | + | player's first key that begins with ''cl''. | |
| − | + | * The colour isn't checked; see [[Manual:DIL Manual/addcolor()|addcolor()]] for the values the | |
| − | + | <code>color</code> command accepts. | |
| − | + | * Personal colours only change what telnet players see. | |
| − | + | == Example == | |
| − | + | <pre> | |
| + | 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 | ||
| + | </pre> | ||
| + | A player command <code>clancolor <colour></code> that changes the player's | ||
| + | <code>clan_who</code> colour, or adds it the first time. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/addcolor()|addcolor()]] | ||
| + | * [[Manual:DIL Manual/delcolor()|delcolor()]] | ||
| + | * [[Manual:DIL Manual/getcolor()|getcolor()]] | ||
Latest revision as of 23:04, 14 November 2026
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.