Module:HeroData/doc: Difference between revisions
m write_stat_boxes > write_stat_infoboxes |
m sig_figs example; spacing |
||
Line 22: | Line 22: | ||
Which outputs | Which outputs | ||
{{#invoke:HeroData|write_infobox|Abrams}} | {{#invoke:HeroData|write_infobox|Abrams}} | ||
Line 36: | Line 35: | ||
Which outputs | Which outputs | ||
{{#invoke:HeroData|write_stat_infoboxes|Abrams}} | |||
=== 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''' - OPTIONAL, # of sig figs to round to if retrieving a float | |||
====Examples==== | |||
From wikitext<br>: | |||
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre> | |||
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}} | |||
<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}</pre> | |||
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}} | |||
{{#invoke:HeroData| | <pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre> | ||
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}} | |||
====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. | |||
=== get_localized_var === | === get_localized_var === | ||
Line 48: | Line 73: | ||
====Examples==== | ====Examples==== | ||
From wikitext:<br> | From wikitext:<br> | ||
<pre>{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}}</pre | <pre>{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}}</pre> | ||
{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}} | {{#invoke:HeroData|get_localized_var|Abrams|WeaponName}} | ||
<pre>{{#invoke:HeroData|get_localized_var|Abrams|Role}}</pre | |||
<pre>{{#invoke:HeroData|get_localized_var|Abrams|Role}}</pre> | |||
{{#invoke:HeroData|get_localized_var|Abrams|Role}} | {{#invoke:HeroData|get_localized_var|Abrams|Role}} | ||
====Notes==== | ====Notes==== | ||
Line 64: | Line 91: | ||
* WeaponName | * WeaponName | ||
* TODO each value in WeaponTypes | * TODO each value in WeaponTypes | ||
Revision as of 02:37, 22 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
See Template:Lang for more
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:
{{#invoke:HeroData|write_infobox|HERO_NAME}}
Which outputs Hero Abrams Not Found
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:
{{#invoke:HeroData|write_stat_infoboxes|HERO_NAME}}
Which outputs Hero Not Found
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 - OPTIONAL, # of sig figs to round to if retrieving a float
Examples
From wikitext
:
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
570
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}
20.0000108
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}
20
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.
get_localized_var
Get a hero's stat, then localize it
Parameters
- hero_name - Name of the hero, in english
- hero_var - Key of the hero's variable, see Data:HeroData.json
Examples
From wikitext:
{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}}
Script error: The function "get_localized_var" does not exist.
{{#invoke:HeroData|get_localized_var|Abrams|Role}}
Script error: The function "get_localized_var" does not exist.
Notes
Only usable on variables that can be localized. 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).
As of writing this (not exhaustive), localizable variables include:
- Lore
- Playstyle
- Role
- WeaponDescription
- WeaponName
- TODO each value in WeaponTypes