Module:HeroData/doc: Difference between revisions
m get_list_elem added |
m get_list_elem examples |
||
Line 81: | Line 81: | ||
* '''number''' - Index to retrieve from the list. 1 for 1st element, 2 for 2nd element, etc. | * '''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. | * '''localize''' - OPTIONAL - "true" if its a string that should be localized. See Localizable values section. | ||
==== Example ==== | |||
From wikitext:<br> | |||
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes}}</pre> | |||
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes}} | |||
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|true}}</pre> | |||
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|true}} | |||
== Localizable values == | == Localizable values == |
Revision as of 03:42, 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
“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_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
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}}
600
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}
21.9964
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}
22
{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}
Charges into close combat
{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}
Case Closed
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}}
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|true}}
Localizable values
Localizable values as of writing this:
- Lore
- Playstyle
- Role
- WeaponDescription
- WeaponName