Module:HeroData/doc: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m reference to StatBox moved to Infobox_stat
Sur (talk | contribs)
m write_hero_comparison_table and reordered functions
Line 10: Line 10:


== 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: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}}


=== get_hero_var ===
=== get_hero_var ===
Line 90: Line 64:
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}</pre>
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}</pre>
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}
{{#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 ==

Revision as of 22:05, 26 September 2024

Overview

This module provides functions to create hero infoboxes, statboxes, or retrieve hero information using the data uploaded to Data:HeroData.json.

Both will automatically be translated depending on the language selected. If called on

  • Page - translates to english
  • Page/en - translates to english
  • Page/es - translates to spanish

See Template:Lang for more

Functions

get_hero_var

Retrieve a hero variable's value, such as Abram's MaxHealth

Parameters

  • hero_name - Name of the hero, in english
  • 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. See Localizable values section.

Examples

From wikitext:

{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}

800


{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}

17


{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}

17


{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}

Charges into close combat


{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}

0

Notes

Only usable on variables that are integers, strings, or floats (meaning not dictionaries/hashes or arrays/lists).

If using sig_figs parameter, ensure the value is a float.

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
  • 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:

{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2}}

Attribute_EWeaponAttribute_CloseRange


{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}

Close Range

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:

{{#invoke:HeroData|write_infobox|HERO_NAME}}

Which outputs Script error: The function "write_infobox" does not exist.

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:

{{#invoke:HeroData|write_stat_infoboxes|HERO_NAME}}

Which outputs Script error: The function "write_stat_infoboxes" does not exist.

write_hero_comparison_table

Writes the Hero Comparison table for a specific Level and Spirit Power

Parameters

  • level - Number of Levels / 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:

{{#invoke:HeroData|write_hero_comparison_table|LEVEL|SPIRITPOWER}}

Which outputs Script error: The function "write_hero_comparison_table" does not exist.

Localizable values

Localizable values as of writing this:

  • Lore
  • Playstyle
  • Role
  • WeaponDescription
  • WeaponName
  • elements in WeaponTypes