Difference between revisions of "Manual:DIL Manual/getcolor()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bfgcolor"></span>
+
= getcolor() =
 +
'''Function''' (string). Returns the HTML tag that starts text in a named colour.
  
−
  '''Function:  '''<i><!--CODE--> string getcolor (ch : unitptr, ks : string) ;</i><!--ENDCODE-->
+
  getcolor(key : string)
  
−
<!--TERM--> '''ch'''
+
Returns <code>&lt;div class='key'&gt;</code>, nothing more: it is a short way to write the tag.
−
<!--DEFINITION-->         character you are deleting the color from
+
Text inside it is shown in the reader's colour for <code>key</code>. For a telnet player that
−
<!--TERM--> '''ks'''
+
is the colour they chose with the <code>color</code> command, or one a DIL gave them with
−
<!--DEFINITION-->         key string for the color
+
[[Manual:DIL Manual/addcolor()|addcolor()]], and otherwise the game's default from
−
<!--TERM--> '''returns'''
+
<code>vme/etc/color.def</code> (<code>default</code>, <code>say_self</code>, <code>clan</code>,
−
<!--DEFINITION-->         returns the color in a string
+
...). The web client gets the class as it is and colours it with its own style sheet.
  
−
This function returns what color a player has for a key in the players list.
+
== Parameters ==
−
'''Function:  '''<i><!--CODE-->string := getcolor(pc, "clan_who");</i><!--ENDCODE-->
+
{| class="wikitable"
−
<span id="bfgcolor"></span>
+
! Name !! Type !! Meaning
 +
|-
 +
| key || string || The colour's name, the class of the <code>div</code>.
 +
|}
  
−
'''Function: '''<i><!--CODE--> string getcolor (ch : unitptr, ks : string) ;</i><!--ENDCODE-->
+
== Returns ==
 +
String: <code>&lt;div class='key'&gt;</code>. A string variable that was never set gives
 +
<code>&lt;div class=''&gt;</code>.
  
−
<!--TERM-->  '''ch'''
+
== Notes ==
−
<!--DEFINITION-->         character you are deleting the color from
+
* It does not read a player's colours, and it takes no unit: the old manual's
−
<!--TERM--> '''ks'''
+
  <code>getcolor(ch, key)</code> doesn't compile.
−
<!--DEFINITION-->        key string for the color
+
* Close the colour with <code>&lt;/div&gt;</code>.
−
<!--TERM--> '''returns'''
 
−
<!--DEFINITION-->         returns the color in a string
 
  
−
This function returns what color a player has for a key in the players list.
+
== Example ==
−
'''Function:  '''<i><!--CODE-->string := getcolor(pc, "clan_who");</i><!--ENDCODE-->
+
<pre>
 +
dilbegin clan_tell(pc : unitptr, msg : string);
 +
code
 +
{
 +
  sendtext(getcolor("clan") + msg + "</div><br/>", pc);
 +
  quit;
 +
}
 +
dilend
 +
</pre>
 +
Sends a line in the reader's clan colour, the same as writing
 +
<code>&lt;div class='clan'&gt;</code> as clans.zon does.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/addcolor()|addcolor()]]
 +
* [[Manual:DIL Manual/changecolor()|changecolor()]]
 +
* [[Manual:DIL Manual/delcolor()|delcolor()]]
 +
* [[Manual:DIL Manual/sendtext()|sendtext()]]
 +
* [[Manual:DIL Manual/act()|act()]]

Latest revision as of 23:03, 14 November 2026

getcolor()

Function (string). Returns the HTML tag that starts text in a named colour.

getcolor(key : string)

Returns <div class='key'>, nothing more: it is a short way to write the tag. Text inside it is shown in the reader's colour for key. For a telnet player that is the colour they chose with the color command, or one a DIL gave them with addcolor(), and otherwise the game's default from vme/etc/color.def (default, say_self, clan, ...). The web client gets the class as it is and colours it with its own style sheet.

Parameters

Name Type Meaning
key string The colour's name, the class of the div.

Returns

String: <div class='key'>. A string variable that was never set gives <div class=>.

Notes

  • It does not read a player's colours, and it takes no unit: the old manual's
 getcolor(ch, key) doesn't compile.
  • Close the colour with </div>.

Example

dilbegin clan_tell(pc : unitptr, msg : string);
code
{
   sendtext(getcolor("clan") + msg + "</div><br/>", pc);
   quit;
}
dilend

Sends a line in the reader's clan colour, the same as writing <div class='clan'> as clans.zon does.

See also