Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:HeroData/doc: Difference between revisions

From Deadlock Wiki
Sur (talk | contribs)
m get_localized_var now a parameter in get_var
Sur (talk | contribs)
m reference HeroData/nav and HeroData/release
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Documentation|contents=
Also see:
* [[Module:HeroData/nav]] - For nav box purposes
* [[Module:HeroData/release]] - For determining the release status of a hero
== Overview ==
== Overview ==


Line 10: Line 15:


== Functions ==
== Functions ==
=== write_infobox ===
Writes a [[Template:Infobox_hero]] template call for a given hero
====Parameters====
* '''hero_name''' – Name of the hero, in english
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_infobox|HERO_NAME}}</pre>
Which outputs
{{#invoke:HeroData|write_infobox|Abrams}}
=== write_stat_infoboxes ===
Writes all 3 [[Template:StatBox]] template calls (Weapon, Vitality, Spirit) for a given hero
====Parameters====
* '''hero_name''' – Name of the hero, in english
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_stat_infoboxes|HERO_NAME}}</pre>
Which outputs
{{#invoke:HeroData|write_stat_infoboxes|Abrams}}


=== get_hero_var ===
=== get_hero_var ===
Line 41: Line 20:


====Parameters====
====Parameters====
* '''hero_name''' - Name of the hero, in english
* '''hero_name''' - Name of the hero in english, or key of the hero. Preferred and recommended to use hero key, as its much more efficient. Search for the key in [[Data:HeroData.json]]
* '''hero_var''' - Key of the hero's variable, see [[Data:HeroData.json]]
* '''hero_var''' - Key of the hero's variable, see [[Data:HeroData.json]]
* '''sig_figs_or_localize''' - OPTIONAL, # of sig figs to round to if retrieving a float, or "true" if its a string that should be localized
* '''sig_figs_or_localize''' - OPTIONAL, # of sig figs to round to if retrieving a float, or "true" if its a string that should be localized. See Localizable values section.
 
Note: Recommended to use hero key where possible, i.e. hero_atlas as its O(1) time complexity instead of hero name (Abrams) which is O(N).


====Examples====
====Examples====
From wikitext:<br>
From wikitext:<br>
Using hero name in english
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
Using hero key
<pre>{{#invoke:HeroData|get_hero_var|hero_atlas|MaxHealth}}</pre>
{{#invoke:HeroData|get_hero_var|hero_atlas|MaxHealth}}




Line 54: Line 43:
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}


Round to 2 sig figs


<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre>
Line 59: Line 50:




<pre>{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}
{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}


Localize


<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}</pre>
Line 73: Line 66:
If using localize parameter, ensure the value is a string. See [[Data:HeroData.json]], you will notice that hero_astro's "Lore" variable has the value "hero_astro_lore". This key is then sent to [[Module:Lang]] which checks for it in [[Data:Lang_en.json]] (or a different language).
If using localize parameter, ensure the value is a string. See [[Data:HeroData.json]], you will notice that hero_astro's "Lore" variable has the value "hero_astro_lore". This key is then sent to [[Module:Lang]] which checks for it in [[Data:Lang_en.json]] (or a different language).


=== get_list_elem ===
Retrieve a specified element from a list
==== Parameters ====
* '''hero_name''' - Name of the hero in english, or hero key. Preferred and recommended to use hero key, as its much more efficient. Search for the key in [[Data:HeroData.json]]
* '''hero_var''' - Key of the hero's variable, see [[Data:HeroData.json]]
* '''number''' - Index to retrieve from the list. 1 for 1st element, 2 for 2nd element, etc.
* '''localize''' - OPTIONAL - "true" if its a string that should be localized. See Localizable values section.
==== Example ====
From wikitext:<br>
Using hero name in english
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2}}</pre>
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2}}
Using hero key
<pre>{{#invoke:HeroData|get_list_elem|hero_atlas|WeaponTypes|2}}</pre>
{{#invoke:HeroData|get_list_elem|hero_atlas|WeaponTypes|2}}
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}</pre>
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}
=== write_infobox ===
Writes a [[Template:Infobox_hero]] template call for a given hero
====Parameters====
* '''hero_name''' – Name of the hero, in english
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_infobox|HERO_NAME}}</pre>
Which outputs
{{#invoke:HeroData|write_infobox|Abrams}}
=== write_stat_infoboxes ===
Writes all 3 [[Template:Infobox_stat]] template calls (Weapon, Vitality, Spirit) for a given hero
====Parameters====
* '''hero_name''' – Name of the hero, in english
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_stat_infoboxes|HERO_NAME}}</pre>
Which outputs
{{#invoke:HeroData|write_stat_infoboxes|Abrams}}
=== write_hero_comparison_table ===
Writes the [[Hero Comparison]] table for a specific Level and Spirit Power
====Parameters====
* '''level''' - Number of [[Level]]s / Power Increases
* '''spirit_power''' - Amount of Spirit power
Both parameters are optional, as if both are 0 or not provided, the outputted table will be at base and will also include the level/SS scaling in each cell along with the base value, rather than the scaled value.
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_hero_comparison_table|LEVEL|SPIRITPOWER}}</pre>
Which outputs
{{#invoke:HeroData|write_hero_comparison_table|11|200}}
== Localizable values ==
Localizable values as of writing this:
Localizable values as of writing this:
* Lore
* Lore
Line 79: Line 139:
* WeaponDescription
* WeaponDescription
* WeaponName
* WeaponName
* elements in WeaponTypes
* elements in RecommendedItems
}}