Module:HeroData/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
initial
 
Sylphoid (talk | contribs)
testing styling
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Documentation|contents=
== Overview ==
== Overview ==


This module provides functions to create hero infoboxes or statboxes (and more miscellaneous items).
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
Both will automatically be translated depending on the language selected. If called on
Line 9: Line 10:
See [[Template:Lang]] for more
See [[Template:Lang]] for more


=== Functions ===
== Functions ==


* '''write_infobox''' – Writes a [[Template:Infobox_hero]] template call for a given hero
=== get_hero_var ===
* '''write_stat_boxes''' – Writes all 3 [[Template:StatBox]] template calls (Weapon, Vitality, Spirit) for a given hero
Retrieve a hero variable's value, such as Abram's MaxHealth


=== Parameters ===
====Parameters====
Both functions use one parameter.
* '''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:<br>
Using hero name in english
 
<pre>{{#invoke:HeroData|get_hero_var|Abrams|MaxHealth}}</pre>
{{#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}}
 
 
<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange}}
 
 
Round to 2 sig figs
 
<pre>{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|FalloffStartRange|2}}
 
 
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|WeaponName}}
 
 
Localize
 
<pre>{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}</pre>
{{#invoke:HeroData|get_hero_var|Abrams|WeaponName|true}}
 
====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:<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
* '''hero_name''' – Name of the hero, in english


=== Examples ===
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_infobox|HERO_NAME}}</pre>


To use this module from wikitext, use
Which outputs
{{#invoke:HeroData|write_infobox|Abrams}}


<pre>{{#invoke:HeroData|write_stat_boxes|HERO_NAME}}</pre>
=== 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
Which outputs
{{#invoke:HeroData|write_stat_infoboxes|Abrams}}
=== write_hero_comparison_table ===
Writes the [[Hero Comparison]] table for a specific Level and Spirit Power


{{#invoke:HeroData|write_infobox|Abrams}}
====Parameters====
* '''level''' - Number of [[Level]]s / Power Increases
* '''spirit_power''' - Amount of Spirit power


<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
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.
or


<pre>{{#invoke:HeroData|write_infobox|HERO_NAME}}</pre>
====Example====
From wikitext:<br>
<pre>{{#invoke:HeroData|write_hero_comparison_table|LEVEL|SPIRITPOWER}}</pre>


Which outputs
Which outputs
{{#invoke:HeroData|write_hero_comparison_table|11|200}}


{{#invoke:HeroData|write_stat_boxes|Abrams}}
== Localizable values ==
Localizable values as of writing this:
* Lore
* Playstyle
* Role
* WeaponDescription
* WeaponName
* elements in WeaponTypes
* elements in RecommendedItems
}}

Latest revision as of 17:46, 1 November 2024

Module documentation [edit] [purge]

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 Talon12095.665.81.820172.35011092.4170false4950.8185408472.500011.3054
Bebop11277.28.9312.50662.35011092.4170false5080.82250.8851110031010.506.55353
Haze80.696.98.061001252.35011092.4170false7621.52246079720008.3053
Abrams112657.441.67090.3530.70591092.4170true6100.82045.7094410006.8053
Seven11173.918.140292.350130.0892.4170false6350.82257.50891300-3511.7053
Wraith10766.99.6511.10522.82011092.4170false57202257.5089120007.31253
Warden16888.330.26.460172.91011092.4170false2900.252257.50105020006.3153
Dynamo83.154.620.840182.35011092.4170false3200.82257.501130210.5006.8053
Lady Geist95.966.543.22.220132.59011092.4170false8280.82257.50110010006.31.553
Mirage82.956.6292.860162.6011092.4170false8280.82257.5095720007.3053
Yamato1191189.532.50422.44051098.4183false25402245.7084120008.3053
Vindicta11668.321.85.8228222.91011092.4170false8890.82264077020009052
Ivy12862.28.9614.30332.44011092.4170false5720.82257.5093520007.3054
Lash10368.716.840292.350130.0892.4170false6350.82257.501010201507.3153
Mo & Krill12871.85.765.560202.82041092.4170false3200.82257.501180300-208.1053
Shiv10568.39.161.90102.8061092.4170false6100.819.841.1098520007053
Pocket11878.38.4620112.820710104161false5590.81645.7089120-1507.3053
Kelvin1156828.740152.59011092.4170false2540.32257.501150201006.8053
Infernus97.150.59.71100272.49011092.4170false6600.82257.5096320006.8053
Viscous10564.320.950202.5011092.4170false25402257.5096820007.3053
Paradox96.463.712.23.570402.590150.0792.4170false5250.12257.5099020006.8053
McGinnis54.843.81150663.29011092.4170false5330.82257.501000215006.8052

Localizable values

Localizable values as of writing this:

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