Template:UnitData: Difference between revisions

From Mechabellum Wiki
(test vardef and single value)
(add help)
Line 21: Line 21:
<!-- ----------------------------- end data ----------------------------- -->
<!-- ----------------------------- end data ----------------------------- -->
   }}
   }}
}}{{#iferror: {{#expr: {{#sub:{{#var:row}}|-1}} }}
}}<noinclude>
This template contains all unit data (HP, Speed, Attack, (Attack) Interval, Range, Splash (Range), Target, Units, Giant, Mobility, Cost, Unlock Cost)
 
Using the Template with a unit name sets the variables ''<nowiki>{{UnitData|Fortress}}</nowiki>''
 
On the unit pages the data is automatically pulled and placed in variables (hp, speed, atk, atkint, range, splash, target, units, giant, mobility, cost, unlockcost, burst, dps), ready to use on the page with e.g. ''<nowiki>{{#var:speed}}</nowiki>''.
 
A single value can be pulled without overriding the variables  ''<nowiki>{{UnitData|Fortress|speed}}</nowiki>''.
 
Melting damage is set as a range "1 - 9000" allowing the math to work.
 
Missiles usually cam in packs of 4 but the damage/attack shown is for one missile, so add a multiplier e.g. "555 * 4" looks nicer and math works fine.
 
<hr></noinclude>{{#iferror: {{#expr: {{#sub:{{#var:row}}|-1}} }}
   | Error: Unit "{{{1|{{PAGENAME}}}}}" undefined!
   | Error: Unit "{{{1|{{PAGENAME}}}}}" undefined!
   | <!-- no error -  -->
   | <!-- no error -  -->
   {{#if:{{{2|}}}
   {{#if:{{{2|}}}
     |<!-- return val --> {{#switch: {{{2}}}
     |<!-- return val --> {{#switch: {{{2}}}
       | #default =
       | #default = Error: Var "{{{2}}}" undefined!
       | hp = {{#explode: {{#var:row}} | ; | 0 }}
       | hp = {{#explode: {{#var:row}} | ; | 0 }}
       | speed = {{#explode: {{#var:row}} | ; | 1 }}
       | speed = {{#explode: {{#var:row}} | ; | 1 }}

Revision as of 17:18, 8 June 2023

This template contains all unit data (HP, Speed, Attack, (Attack) Interval, Range, Splash (Range), Target, Units, Giant, Mobility, Cost, Unlock Cost)

Using the Template with a unit name sets the variables {{UnitData|Fortress}}

On the unit pages the data is automatically pulled and placed in variables (hp, speed, atk, atkint, range, splash, target, units, giant, mobility, cost, unlockcost, burst, dps), ready to use on the page with e.g. {{#var:speed}}.

A single value can be pulled without overriding the variables {{UnitData|Fortress|speed}}.

Melting damage is set as a range "1 - 9000" allowing the math to work.

Missiles usually cam in packs of 4 but the damage/attack shown is for one missile, so add a multiplier e.g. "555 * 4" looks nicer and math works fine.


Error: Unit "UnitData" undefined!