Module:Utilities/doc: Difference between revisions

Sur (talk | contribs)
m get_slot_color with alpha colored divs
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Overview=
==Overview==
Utility functions that serve any miscellaneous purpose
Utility functions that serve any miscellaneous purpose


=Functions=
==Functions==


==get_slot_color==
==get_slot_color==
Retrieve's the hex color of a certain slot/category, formerly known in english as Weapon, Vitality, and Spirit, though their unlocalized names are Weapon, Armor, and Tech.
Retrieve's the color of a certain slot/category in any color format (default hex), formerly known in english as Weapon, Vitality, and Spirit, though their unlocalized names are Weapon, Armor, and Tech. Utilized by [[Template:Color]]


===Parameters===
===Parameters===
* '''slot''' - slot key, options are Weapon, Armor, and Tech
* '''slot''' - slot key, options are Weapon, Armor, and Tech
* '''color_format''' - color format, defaults to hex. Valid options are hex, rgb, hsl, cmyk
* '''color_format''' - color format - Defaults to hex. Valid options are hex, rgb, hsl, cmyk
* '''no_wrap''' - Defaults to false. Set to true to remove prefixes and postfixes of '#' from hex, or 'rgb()', 'hsl()', and 'cmyk()' from the other formats. May be useful for altering the values dynamically
* '''no_wrap''' - (OPTIONAL) - Defaults to false. Set to true to remove prefixes and postfixes of '#' from hex, or 'rgb()', 'hsl()', and 'cmyk()' from the other formats. May be useful for altering the values dynamically
* '''debug_mode''' - (OPTIONAL) - used mostly for documentation purposes
* '''debug_mode''' - (OPTIONAL) - Defaults to false. Used mostly for documentation purposes


===Examples===
===Examples===
To retrieve the hex color
See examples at [[Template:Color]]
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech}}</nowiki></code>


{{#invoke:Utilities|get_slot_color|Tech|debug_mode=true}}
==remove_trailing_colon==
Remove's the ":" character from the end of a string


To retrieve other color formats
===Examples===
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech|rgb}}</nowiki></code>
<pre>{{#invoke:Utilities|remove_trailing_colon|A Fate's Tale:}}</pre>


{{#invoke:Utilities|get_slot_color|Tech|rgb|debug_mode=true}}
{{#invoke:Utilities|remove_trailing_colon|A Fate's Tale:}}


==process_variables==
Processes a localized string by replacing variable patterns with their corresponding values.


To style text:
===Parameters===
<code><nowiki><span style="color: {{#invoke:Utilities|get_slot_color|Weapon}};">Weapon colored text</span></nowiki></code>
* string_key - The localization key used to retrieve the base string (via Module:Lang)


<span style="color: {{#invoke:Utilities|get_slot_color|Weapon}};">Weapon colored text</span>
* item_name - The name of the item used to look up variable values (via Module:ItemData)


===Examples===
Active Item descriptions in [[Template:Active Items]]
<pre>{{#invoke:Utilities|process_variables|upgrade_thermal_detonator_desc|Alchemical Fire}}</pre>


To style divs:
{{#invoke:Utilities|process_variables|upgrade_thermal_detonator_desc|Alchemical Fire}}
<code><nowiki><div style="background-color: {{#invoke:Utilities|get_slot_color|Tech}};">
Tech colored div</div></nowiki></code>
 
<div style="background-color: {{#invoke:Utilities|get_slot_color|Tech}};">
Tech colored div
</div>
 
 
To alter the alpha value using rgb dynamically:
<code><nowiki><div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.5);">
Armor colored div with 0.5 alpha</div></nowiki></code>
 
<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.5);">
Armor colored div with 0.5 alpha
</div>
 
 
<code><nowiki><div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.2);">
Armor colored div with 0.2 alpha</div></nowiki></code>
 
<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.2);">
Armor colored div with 0.2 alpha
</div>