Template:Stat Color: Difference between revisions
imported>Koanyan5028 Created page with "<includeonly>{{#switch: {{lc: {{{1}}} }} | defense | defence=#5555ff | attack=#55ffff | speed=#55ff55 | evasion=#ffff55 | health=#ff5555 | vitality=#ff55ff | crit | critical | crit chance | critical chance | critchance | criticalchance=#aa00aa | #default=#ffffff }}</includeonly><noinclude> <span style="color:{{Stat Color|defense}}">Defense</span> <span style="color:{{Stat Color|speed}}">Speed</span> This template returns color code corresponding to the stat specified..." |
imported>Koanyan5028 mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 14: | Line 14: | ||
| criticalchance=#aa00aa | | criticalchance=#aa00aa | ||
| #default=#ffffff | | #default=#ffffff | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude>{{Documentation}}</noinclude> | ||
Latest revision as of 11:52, 28 October 2024
Template:Stat Color returns the standard hex colour code for a named stat, so stat colours stay consistent everywhere on the wiki.
Overview
This template takes a stat name as its first unnamed parameter and outputs only a hex colour code (e.g. speed → #55ff55). It outputs nothing visible on its own — you place it inside a style="color:..." attribute or pass it to another template. It is case-insensitive and accepts several aliases. Unknown names fall back to white (#ffffff). It is used by Template:Stat Bar (and therefore Template:Stat Table) to colour stat bars.
Parameters
| Parameter | Required? | What it does | Example |
|---|---|---|---|
1 (first unnamed parameter) |
Required | The stat name to look up. Recognised values (case-insensitive): defense/defence → #5555ff; attack → #55ffff; speed → #55ff55; evasion → #ffff55; health → #ff5555; vitality → #ff55ff; crit/critical/crit chance/critical chance/critchance/criticalchance → #aa00aa. Anything else returns #ffffff (white). |
|
How to use
1. Write {{Stat Color| followed by the stat name, then }}.
2. Put that wherever a colour value is expected — most often inside a span style.
Special-syntax notes: the name is the first positional argument (no name=), and it is not case-sensitive, so speed, Speed and SPEED all return the same colour. Several aliases map to the same colour (e.g. defense and defence; the six crit spellings). A name the template doesn't recognise returns white rather than an error.
Copy this
<span style="color:{{Stat Color|}}">your text</span>Example
Live result:
Attack
Wikitext that produced it:
<span style="color:{{Stat Color|attack}}">Attack</span>Used on its own, it just emits the code:
{{Stat Color|speed}} produces: #55ff55Tips & notes
- Case doesn't matter; aliases exist for defence/defense and for the six crit spellings.
- Unrecognised names return
#ffffff(white), not an error — double-check spelling if a colour comes out white unexpectedly. - The template emits only the hex code, so always wrap it in something that consumes a colour (e.g.
style="color:..."). - Related: Template:Stat Bar and Template:Stat Table both rely on this for their colours.