From Dark and Darker Wiki

< Module:Utilities

(overview and insert_space_before_capitals init)
 
m (artifact rarity supported)
 
(4 intermediate revisions by the same user not shown)
Line 16: Line 16:


{{#invoke:Utilities|insert_space_before_capitals|ElementalBolt}}
{{#invoke:Utilities|insert_space_before_capitals|ElementalBolt}}
==dash_for_space==
Replaces all spaces with dashes. i.e. "Physical Damage" -> "Physical Damage". Useful for turning text into something that can be used as a css class.
See [[Module:Enchantments]] for an example that utilizes this module.
===Parameters===
* ''input_text'' - input string
===Examples===
<pre>{{#invoke:Utilities|dash_for_space|Physical Damage}}</pre>
{{#invoke:Utilities|dash_for_space|Physical Damage}}
<!--why is there a 1 trailing the example here..? it works in the enchantment module just fine-->
==rarity_name_to_num==
Translates the rarity name to its corresponding number, where Junk has numerical equivalent of 0, up to Artifact as 8.
Used by draw_socket_cost_table() in [[Module:Enchantments]] to determine the order and css class for each rarity.
===Parameters===
* ''rarity_name'' - Name of the rarity: Junk, Poor, Common, Uncommon, Rare, Epic, Legend, Unique, and Artifact
===Examples===
<pre>{{#invoke:Utilities|rarity_name_to_num|Poor}}</pre>
{{#invoke:Utilities|rarity_name_to_num|Poor}}
==rarity_num_to_name==
Translates the rarity number to its corresponding name, where Junk has numerical equivalent of 0, up to Artifact as 8.
===Parameters===
* ''rarity_num'' - Number of the rarity: 0, 1, 2, 3, 4, 5, 6, 7, 8
===Examples===
<pre>{{#invoke:Utilities|rarity_num_to_name|1}}</pre>
{{#invoke:Utilities|rarity_num_to_name|1}}

Latest revision as of 21:46, 3 May 2025

Overview

Utility functions

Functions

insert_space_before_capitals

Adds spaces before capital letters (other than if its the first character). i.e. "ElementalBolt" -> "Elemental Bolt"

Can be invoked within wikitext, or called within another lua module. See Module:MergeSpells for an example that utilizes this module.

Parameters

  • input_text - input string

Examples

{{#invoke:Utilities|insert_space_before_capitals|ElementalBolt}}

Elemental Bolt

dash_for_space

Replaces all spaces with dashes. i.e. "Physical Damage" -> "Physical Damage". Useful for turning text into something that can be used as a css class.

See Module:Enchantments for an example that utilizes this module.

Parameters

  • input_text - input string

Examples

{{#invoke:Utilities|dash_for_space|Physical Damage}}

Physical-Damage1


rarity_name_to_num

Translates the rarity name to its corresponding number, where Junk has numerical equivalent of 0, up to Artifact as 8.

Used by draw_socket_cost_table() in Module:Enchantments to determine the order and css class for each rarity.

Parameters

  • rarity_name - Name of the rarity: Junk, Poor, Common, Uncommon, Rare, Epic, Legend, Unique, and Artifact

Examples

{{#invoke:Utilities|rarity_name_to_num|Poor}}

1


rarity_num_to_name

Translates the rarity number to its corresponding name, where Junk has numerical equivalent of 0, up to Artifact as 8.

Parameters

  • rarity_num - Number of the rarity: 0, 1, 2, 3, 4, 5, 6, 7, 8

Examples

{{#invoke:Utilities|rarity_num_to_name|1}}

Poor