Editing Module:Utilities/doc

Jump to navigation Jump to search
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
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 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]]
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.


===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''' - (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
* '''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
* '''debug_mode''' - (OPTIONAL) - Defaults to false. Used mostly for documentation purposes
* '''debug_mode''' - (OPTIONAL) - used mostly for documentation purposes


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


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


===Examples===
To retrieve other color formats
<pre>{{#invoke:Utilities|remove_trailing_colon|A Fate's Tale:}}</pre>
<code><nowiki>{{#invoke:Utilities|get_slot_color|Tech|rgb}}</nowiki></code>
 
{{#invoke:Utilities|get_slot_color|Tech|rgb|debug_mode=true}}
 
 
To style text:
<code><nowiki><span style="color: {{#invoke:Utilities|get_slot_color|Weapon}};">Weapon colored text</span></nowiki></code>
 
<span style="color: {{#invoke:Utilities|get_slot_color|Weapon}};">Weapon colored text</span>
 
 
To style divs:
<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>


{{#invoke:Utilities|remove_trailing_colon|A Fate's Tale:}}


==process_variables==
To alter the alpha value using rgb dynamically:
Processes a localized string by replacing variable patterns with their corresponding values.
<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>


===Parameters===
<div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.5);">
* string_key - The localization key used to retrieve the base string (via Module:Lang)
Armor colored div with 0.5 alpha
</div>


* item_name - The name of the item used to look up variable values (via Module:ItemData)


===Examples===
<code><nowiki><div style="background-color: rgb({{#invoke:Utilities|get_slot_color|Armor|rgb|no_wrap=true}}, 0.2);">
Active Item descriptions in [[Template:Active Items]]
Armor colored div with 0.2 alpha</div></nowiki></code>
<pre>{{#invoke:Utilities|process_variables|upgrade_thermal_detonator_desc|Alchemical Fire}}</pre>


{{#invoke:Utilities|process_variables|upgrade_thermal_detonator_desc|Alchemical Fire}}
<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>
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Pages included on this page: