Module:HeroData/doc: Difference between revisions
initial |
m documentation expanded greatly |
||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
This module provides functions to create hero infoboxes or statboxes (and more miscellaneous items). | This module provides functions to create hero infoboxes or statboxes (and more miscellaneous items) using the data uploaded to [[Data:HeroData.json]]. | ||
Both will automatically be translated depending on the language selected. If called on | Both will automatically be translated depending on the language selected. If called on | ||
Line 9: | Line 9: | ||
See [[Template:Lang]] for more | See [[Template:Lang]] for more | ||
== Functions == | |||
=== write_infobox === | |||
Writes a [[Template:Infobox_hero]] template call for a given hero | |||
=== Parameters === | ====Parameters==== | ||
* '''hero_name''' – Name of the hero, in english | * '''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_boxes === | |||
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_boxes|HERO_NAME}}</pre> | <pre>{{#invoke:HeroData|write_stat_boxes|HERO_NAME}}</pre> | ||
Which outputs | Which outputs | ||
{{#invoke:HeroData| | {{#invoke:HeroData|write_stat_boxes|Abrams}} | ||
=== 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:<br> | |||
<pre>{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}}</pre><br> | |||
{{#invoke:HeroData|get_localized_var|Abrams|WeaponName}} | |||
<pre>{{#invoke:HeroData|get_localized_var|Abrams|Role}}</pre><br> | |||
{{#invoke:HeroData|get_localized_var|Abrams|Role}} | |||
====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 | |||
=== 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]] | |||
<pre>{{#invoke:HeroData| | ====Examples==== | ||
From wikitext<br>: | |||
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre><br> | |||
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}} | |||
<pre>{{#invoke:HeroData|get_hero_var|Abrams|Stamina}}</pre><br> | |||
{{#invoke:HeroData|get_hero_var|Abrams|Stamina}} | |||
====Notes==== | |||
Only usable on variables that are integers, strings, or floats (meaning not dictionaries/hashes or arrays/lists). |
Revision as of 01:44, 22 September 2024
Overview
This module provides functions to create hero infoboxes or statboxes (and more miscellaneous items) 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
“Charges into close combat
Abrams has the bulk and sustain to lead from the front, often running into the middle of his foes and watching them scatter. If his enemies waste their fire on him, his backline teammates can lay out damage with impunity.
write_stat_boxes
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_boxes|HERO_NAME}}
Which outputs
Script error: The function "write_stat_boxes" does not exist.
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
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
Examples
From wikitext
:
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
600
{{#invoke:HeroData|get_hero_var|Abrams|Stamina}}
3
Notes
Only usable on variables that are integers, strings, or floats (meaning not dictionaries/hashes or arrays/lists).