Module:HeroData/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m get_localized_var now a parameter in get_var
Sur (talk | contribs)
m reference HeroData/nav and HeroData/release
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Documentation|contents=
Also see:
* [[Module:HeroData/nav]] - For nav box purposes
* [[Module:HeroData/release]] - For determining the release status of a hero
== Overview ==
== Overview ==


Line 10: Line 15:


== 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: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_infoboxes|HERO_NAME}}</pre>
Which outputs
{{#invoke:HeroData|write_stat_infoboxes|Abrams}}


=== get_hero_var ===
=== get_hero_var ===
Line 41: Line 20:


====Parameters====
====Parameters====
* '''hero_name''' - Name of the hero, in english
* '''hero_name''' - Name of the hero in english, or key of the hero. Preferred and recommended to use hero key, as its much more efficient. Search for the key in [[Data:HeroData.json]]
* '''hero_var''' - Key of the hero's variable, see [[Data:HeroData.json]]
* '''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
* '''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.
 
Note: Recommended to use hero key where possible, i.e. hero_atlas as its O(1) time complexity instead of hero name (Abrams) which is O(N).


====Examples====
====Examples====
From wikitext:<br>
From wikitext:<br>
Using hero name in english
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}
Using hero key
<pre>{{#invoke:HeroData|get_hero_var|hero_atlas|MaxHealth}}</pre>
{{#invoke:HeroData|get_hero_var|hero_atlas|MaxHealth}}




Line 54: Line 43:
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}


Round to 2 sig figs


<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre>
Line 59: Line 50:




<pre>{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|Role|true}}
{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}


Localize


<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}</pre>
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}</pre>
Line 73: Line 66:
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).
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, or hero key. Preferred and recommended to use hero key, as its much more efficient. Search for the key in [[Data:HeroData.json]]
* '''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:<br>
Using hero name in english
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2}}</pre>
{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2}}
Using hero key
<pre>{{#invoke:HeroData|get_list_elem|hero_atlas|WeaponTypes|2}}</pre>
{{#invoke:HeroData|get_list_elem|hero_atlas|WeaponTypes|2}}
<pre>{{#invoke:HeroData|get_list_elem|Abrams|WeaponTypes|2|true}}</pre>
{{#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 as of writing this:
Localizable values as of writing this:
* Lore
* Lore
Line 79: Line 139:
* WeaponDescription
* WeaponDescription
* WeaponName
* WeaponName
* elements in WeaponTypes
* elements in RecommendedItems
}}

Latest revision as of 23:39, 23 November 2024

Module documentation [edit] [purge]

Also see:

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, or key of the hero. Preferred and recommended to use hero key, as its much more efficient. Search for the key in Data:HeroData.json
  • 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.

Note: Recommended to use hero key where possible, i.e. hero_atlas as its O(1) time complexity instead of hero name (Abrams) which is O(N).

Examples

From wikitext:
Using hero name in english

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

570


Using hero key

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

570


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

20.0000108


Round to 2 sig figs

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

20


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

citadel_weapon_hero_atlas_set


Localize

{{#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, or hero key. Preferred and recommended to use hero key, as its much more efficient. Search for the key in Data:HeroData.json
  • 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:
Using hero name in english

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

Attribute_EWeaponAttribute_CloseRange


Using hero key

{{#invoke:HeroData|get_list_elem|hero_atlas|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 Hero Abrams Not Found

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 Hero Not Found

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

HeroDPSSustained DPSBullet DamageBullets per secFire Rate (%)AmmoReload Time (s)Reload Delay (s)Bullets Per ShotBullets Per BurstTime Between Bursted Bullets (s)Light MeleeHeavy MeleeReload SingleBullet Velocity (m/s)Bullet Gravity ScaleFalloff Start RangeFalloff End RangeBonus Attack Range (m)Max HealthHealth RegenBullet Resist (%)Spirit Resist (%)Crit Reduction (%)Move Speed (m/s)Sprint Speed (m/s)Stamina Cooldown (s)Stamina
Grey Talon12197.166.81.820172.35011092.4170false4950.8185408692.500011.3054
Bebop11277.28.9312.50662.35011092.4170false5080.82050.8851110031010.506.55353
Haze80.696.98.061001252.35011092.4170false7621.52046079720008.3053
Abrams112657.441.67090.3530.70591092.4170true6100.82045.709441.50006.8053
Seven11173.918.140292.350130.0892.4170false6350.82057.50891300-3511.7053
Wraith10766.99.6511.10522.82011092.4170false57202057.5089120007.31253
Warden16085.530.2650172.91011092.4170false2900.252057.50105020006.3153
Dynamo83.154.620.840182.35011092.4170false3200.82057.501130210.5006.8053
Lady Geist95.966.543.22.220132.59011092.4170false8280.82057.50110010006.31.553
Mirage82.956.6292.860162.6011092.4170false8280.82057.5095720007.3053
Yamato1191189.532.50422.44051098.4183false25402045.7084120008.3053
Vindicta11668.321.85.8228222.91011092.4170false8890.82064077020009052
Ivy12862.18.9414.30332.44011092.4170false5720.82057.5093520007.3054
Lash10368.716.840292.350130.0892.4170false6350.82057.501010201507.3153
Mo & Krill12871.85.765.560202.82041092.4170false3200.82057.501180300-208.1053
Shiv10568.39.161.90102.8061092.4170false6100.819.841.1098520007053
Pocket11878.38.4620112.820710104161false5590.81645.7089120-1507.3053
Kelvin11568.228.840152.59011092.4170false2540.32057.501150201006.8053
Infernus97.150.59.71100272.49011092.4170false6600.82057.5096320006.8053
Viscous10564.320.950202.5011092.4170false25402057.5096820007.3053
Paradox96.463.712.23.570402.590150.0792.4170false5250.12057.5099020006.8053
McGinnis54.843.81150663.29011092.4170false5900.82057.501000215006.8052

Localizable values

Localizable values as of writing this:

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