Module:HeroData/doc

Revision as of 03:49, 22 September 2024 by Sur (talk | contribs) (→‎Localizable values: elements in WeaponTypes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:HeroData

Overview edit

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 edit

write_infobox edit

Writes a Template:Infobox_hero template call for a given hero

Parameters edit

  • hero_name – Name of the hero, in english

Example edit

From wikitext:

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

Which outputs

Abrams
 
Weapon
"Case Closed"
Reloads single shells at a time. Can be interrupted
DPS   70.1
Ammo   9
Bullets per sec   1.67
Reload Time   0.353s
Vitality
Max Health   600
Bullet Resist   0%
Spirit Resist   0%
Move Speed   6.5m/s

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 edit

Writes all 3 Template:StatBox template calls (Weapon, Vitality, Spirit) for a given hero

Parameters edit

  • hero_name – Name of the hero, in english

Example edit

From wikitext:

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

Which outputs


 
Weapon
  4.68 Bullet Damage ( x0.32)   0% Weapon Damage
  1.67 Bullets per sec   0% Fire Rate
  9 Ammo   0% Clip Size Increase
  0.353s Reload Time   0% Reload Reduction
  610m/s Bullet Velocity   0% Bullet Velocity Increase
  0% Bullet Lifesteal
  63 Light Melee ( x3.4)   116 Heavy Melee ( x6.26)
 
Vitality
  600 Max Health   1 Health Regen
  0% Bullet Resist   0% Spirit Resist
  0 Bullet Shield   0 Spirit Shield
  0% Heal Amp 0% Debuff Resist
  0% Crit Reduction
  6.5m/s Move Speed   0m/s Sprint Speed
5s Stamina Cooldown 0% Stamina Recovery
  3 Stamina
 
Spirit
  0% Ability Cooldown   0% Ability Duration
  0% Ability Range   0% Spirit Lifesteal
  0 Max Charges Increase   0% Charge Cooldown

get_hero_var edit

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

Parameters edit

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

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 edit

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 edit

Retrieve a specified element from a list

Parameters edit

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

From wikitext:

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

Attribute_EWeaponAttribute_CloseRange


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

Close Range

Localizable values edit

Localizable values as of writing this:

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