Template:UnitData: Difference between revisions

From Mechabellum Wiki
m (testing)
(test parameter injection)
Line 1: Line 1:
{{#vardefine:name | {{{1|Fortress}}} }}
{{#vardefine:update | 0.7.6
{{#vardefine:row | {{#switch: {{#var:name|}}
}}<noinclude>{{#vardefine:name | {{{1|{{PAGENAME}}}}}  
<!-- edit the following table only. First row contain the header, Don't change the order! -->
}}{{#vardefine:row | {{#switch: {{#var:name|}}
<!-- Edit the following data. Don't change names and order! -->
  | #default = HP ; Speed ; Attack ; Interval ; Range ; Splash ; Target ; Units ; Giant ; Mobility ; Cost ; Unlock Cost
  | #default = HP ; Speed ; Attack ; Interval ; Range ; Splash ; Target ; Units ; Giant ; Mobility ; Cost ; Unlock Cost
  | Fortress = 54408 ; 6 ; 6843 ; 2 ; 100 ; 4.5 ; Ground Only ; 1 ; Yes ; Ground ; 400 ; 200
  | Fortress = 54408 ; 6 ; 6843 ; 2.0 ; 100 ; 4.5 ; Ground Only ; 1 ; Yes ; Ground ; 400 ; 200
  | Marksman = 1471 ; 8 ; 2271 ; 2.8 ; 140 ; 0 ; Air & Ground ; 1 ; No ; Ground ; 100 ; 0
  | Marksman = 1471 ; 8 ; 2271 ; 2.8 ; 140 ; 0 ; Air & Ground ; 1 ; No ; Ground ; 100 ; 0
  | Vulcan = 37073 ; 6 ; 90 ; 0.1 ; 100 ; 10 ; Ground Only ; 1 ; Yes ; Ground ; 400 ; 100
  | Vulcan = 37073 ; 6 ; 90 ; 0.1 ; 100 ; 10.0 ; Ground Only ; 1 ; Yes ; Ground ; 400 ; 100
  | Melting Point = 39905 ; 6 ; 1 - 6532 ; 0.2 ; 115 ; 3 ; Air & Ground ; 1 ; Yes ; Ground ; 400 ; 200
  | Melting Point = 39905 ; 6 ; 1 - 6532 ; 0.2 ; 115 ; 3.0 ; Air & Ground ; 1 ; Yes ; Ground ; 400 ; 200
  | Rhino = 19297 ; 16 ; 3297 ; 1 ; 0 ; 6 ; Ground Only ; 1 ; No ; Ground ; 200 ; 50
  | Rhino = 19297 ; 16 ; 3297 ; 1.0 ; 0 ; 6.0 ; Ground Only ; 1 ; No ; Ground ; 200 ; 50
  | Wasp = 282 ; 16 ; 189 ; 1.5 ; 50 ; 0 ; Air & Ground ; 12 ; No ; Air ; 200 ; 50
  | Wasp = 282 ; 16 ; 189 ; 1.5 ; 50 ; 0 ; Air & Ground ; 12 ; No ; Air ; 200 ; 50
  | Mustang = 343 ; 16 ; 37 ; 0.4 ; 95 ; 0 ; Air & Ground ; 12 ; No ; Ground ; 200 ; 50
  | Mustang = 343 ; 16 ; 37 ; 0.4 ; 95 ; 0 ; Air & Ground ; 12 ; No ; Ground ; 200 ; 50
Line 13: Line 14:
  | Fang = 117 ; 6 ; 55 ; 1.5 ; 80 ; 0 ; Air & Ground ; 18 ; No ; Ground ; 100 ; 0
  | Fang = 117 ; 6 ; 55 ; 1.5 ; 80 ; 0 ; Air & Ground ; 18 ; No ; Ground ; 100 ; 0
  | Crawler = 261 ; 16 ; 131 ; 1.2 ; 0 ; 0 ; Ground Only ; 24 ; No ; Ground ; 100 ; 0
  | Crawler = 261 ; 16 ; 131 ; 1.2 ; 0 ; 0 ; Ground Only ; 24 ; No ; Ground ; 100 ; 0
  | Overlord = 15321 ; 10 ; 3583 * 4 ; 4 ; 110 ; 7.5 ; Air & Ground ; 1 ; Yes ; Air ; 400 ; 200
  | Overlord = 15321 ; 10 ; 3583 * 4 ; 4.0 ; 110 ; 7.5 ; Air & Ground ; 1 ; Yes ; Air ; 400 ; 200
  | Stormcaller = 1149 ; 6 ; 923 * 4 ; 6.3 ; 180 ; 5.5 ; Ground Only ; 4 ; No ; Ground ; 200 ; 50
  | Stormcaller = 1149 ; 6 ; 923 * 4 ; 6.3 ; 180 ; 5.5 ; Ground Only ; 4 ; No ; Ground ; 200 ; 50
  | Sledgehammer = 3264 ; 7 ; 608 ; 4.5 ; 95 ; 5 ; Ground Only ; 5 ; No ; Ground ; 200 ; 50
  | Sledgehammer = 3264 ; 7 ; 608 ; 4.5 ; 95 ; 5.0 ; Ground Only ; 5 ; No ; Ground ; 200 ; 50
  | Hacker = 3249 ; 8 ; 585 ; 0.3 ; 110 ; 0 ; Ground Only ; 1 ; No ; Ground ; 200 ; 100
  | Hacker = 3249 ; 8 ; 585 ; 0.3 ; 110 ; 0 ; Ground Only ; 1 ; No ; Ground ; 200 ; 100
  | Arclight = 3903 ; 7 ; 397 ; 1.2 ; 90 ; 7 ; Ground Only ; 1 ; No ; Ground ; 100 ; 0
  | Arclight = 3903 ; 7 ; 397 ; 1.2 ; 90 ; 7.0 ; Ground Only ; 1 ; No ; Ground ; 100 ; 0
  | Phoenix = 1623 ; 16 ; 3267 ; 3.2 ; 120 ; 0 ; Air & Ground ; 2 ; No ; Air ; 200 ; 50
  | Phoenix = 1623 ; 16 ; 3267 ; 3.2 ; 120 ; 0 ; Air & Ground ; 2 ; No ; Air ; 200 ; 50
<!-- end table -->
<!-- ----------------------------- end data ----------------------------- -->
}} }}
}} }}
<!-- TEST -->
<!-- output -->
{{#var:row}}
{{#vardefine:mode|{{{mode|param}}} }}
 
<!-- error -->
<!-- table -->
{{#iferror: {{#expr: {{#sub:{{#var:row}}|-1}} }} 
{| class="table table-dark"
  | {{#vardefine:mode|error}} Error: Unit "{{#var:name}}" undefined!
|-
  | <!-- no error - vardefine -->
| {{#var:name}} || {{#replace: {{#var:row}} | ; | {{!}}{{!}} }}
  {{#vardefine:hp | {{#explode: {{#var:row}} | ; | 0 }}
|}
  }}{{#vardefine:speed | {{#explode: {{#var:row}} | ; | 1 }}
 
  }}{{#vardefine:atk | {{#explode: {{#var:row}} | ; | 2 }}
<!-- get value -->
  }}{{#vardefine:atkint | {{#explode: {{#var:row}} | ; | 3 }}
* {{#explode: {{#var:row}} | ; | 0 }} HP
  }}{{#vardefine:range | {{#explode: {{#var:row}} | ; | 4 }}
* Giant? {{#explode: {{#var:row}} | ; | 8 }}
  }}{{#vardefine:splash | {{#explode: {{#var:row}} | ; | 5 }}
  }}{{#vardefine:target | {{#explode: {{#var:row}} | ; | 6 }}
  }}{{#vardefine:units | {{#explode: {{#var:row}} | ; | 7 }}
  }}{{#vardefine:giant | {{#explode: {{#var:row}} | ; | 8 }}
  }}{{#vardefine:mobility | {{#explode: {{#var:row}} | ; | 9 }}
  }}{{#vardefine:cost | {{#explode: {{#var:row}} | ; | 10 }}
  }}{{#vardefine:unlockcost | {{#explode: {{#var:row}} | ; | 11 }}
  }}<!-- calculated variables
  -->{{#vardefine:burst|{{#ifexpr: ({{#var:atk|0}})<1 | 0 | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} round 0 }} }}  
  }}{{#vardefine:dps|
    {{#ifexpr: ({{#var:atk|0}}) < 1 <!-- if melting damage -->
      | {{#expr: {{#explode: {{#var:atk|-0}} | - | 1 }} * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
      | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
    }}
  }}<!-- end vardefine -->
}}
</noinclude><!-- output
-->{{#ifeq: {{#var:mode}} | row |
  {{#var:name}} {{!}}{{!}} {{#replace: {{#var:row}} | ; | {{!}}{{!}} }} {{!}}{{!}} {{#var:dps}} {{!}}{{!}} {{#var:burst}}
}}{{#ifeq: {{#var:mode}} | param |
  name = {{#var:name}}
  {{!}} hp = {{#var:hp}}
  {{!}} speed = {{#var:speed}}
  {{!}} atk = {{#var:atk}}
  {{!}} atkint = {{#var:atkint}}
  {{!}} range = {{#var:range}}
  {{!}} splash = {{#var:splash}}
  {{!}} target = {{#var:target}}
  {{!}} units = {{#var:units}}
  {{!}} giant = {{#var:giant}}
  {{!}} mobility = {{#var:mobility}}
  {{!}} cost = {{#var:cost}}
  {{!}} unlockcost = {{#var:unlockcost}}
  {{!}} dps = {{#var:dps}}
  {{!}} burst = {{#var:burst}}
}}{{#ifeq: {{#var:mode}} | val | {{#var:{{{2|}}} }} }}

Revision as of 14:03, 8 June 2023


Error: Unit "UnitData" undefined!