Template:UnitData: Difference between revisions

From Mechabellum Wiki
(remove noinclude)
(test vardef and single value)
Line 1: Line 1:
{{#vardefine:update | 0.7.6  
{{#vardefine:update | 0.7.6
}}{{#vardefine:name | {{{1|{{PAGENAME}}}}}
}}{{#vardefine:row | {{#switch: {{{1|{{PAGENAME}}}}}
}}{{#vardefine:row | {{#switch: {{#var:name|}}
<!-- Edit the following data. Don't change names and order! -->
<!-- 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
Line 21: Line 20:
  | 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 data ----------------------------- -->
<!-- ----------------------------- end data ----------------------------- -->
}} }}
  }}
<!-- output -->
}}{{#iferror: {{#expr: {{#sub:{{#var:row}}|-1}} }}
{{#vardefine:mode|{{{mode|param}}} }}
   | Error: Unit "{{{1|{{PAGENAME}}}}}" undefined!
<!-- error -->
   | <!-- no error - -->
{{#iferror: {{#expr: {{#sub:{{#var:row}}|-1}} }}
   {{#if:{{{2|}}}
   | {{#vardefine:mode|error}} Error: Unit "{{#var:name}}" undefined!
    |<!-- return val --> {{#switch: {{{2}}}
   | <!-- no error - vardefine -->
      | #default =
   {{#vardefine:hp | {{#explode: {{#var:row}} | ; | 0 }}
      | hp = {{#explode: {{#var:row}} | ; | 0 }}
  }}{{#vardefine:speed | {{#explode: {{#var:row}} | ; | 1 }}
      | speed = {{#explode: {{#var:row}} | ; | 1 }}
  }}{{#vardefine:atk | {{#explode: {{#var:row}} | ; | 2 }}  
      | atk = {{#explode: {{#var:row}} | ; | 2 }}
  }}{{#vardefine:atkint | {{#explode: {{#var:row}} | ; | 3 }}  
      | atkint = {{#explode: {{#var:row}} | ; | 3 }}
  }}{{#vardefine:range | {{#explode: {{#var:row}} | ; | 4 }}
      | range = {{#explode: {{#var:row}} | ; | 4 }}
  }}{{#vardefine:splash | {{#explode: {{#var:row}} | ; | 5 }}
      | splash = {{#explode: {{#var:row}} | ; | 5 }}
  }}{{#vardefine:target | {{#explode: {{#var:row}} | ; | 6 }}
      | target = {{#explode: {{#var:row}} | ; | 6 }}
  }}{{#vardefine:units | {{#explode: {{#var:row}} | ; | 7 }}
      | units = {{#explode: {{#var:row}} | ; | 7 }}
  }}{{#vardefine:giant | {{#explode: {{#var:row}} | ; | 8 }}
      | giant = {{#explode: {{#var:row}} | ; | 8 }}
  }}{{#vardefine:mobility | {{#explode: {{#var:row}} | ; | 9 }}
      | mobility = {{#explode: {{#var:row}} | ; | 9 }}
  }}{{#vardefine:cost | {{#explode: {{#var:row}} | ; | 10 }}
       | cost = {{#explode: {{#var:row}} | ; | 10 }}
  }}{{#vardefine:unlockcost | {{#explode: {{#var:row}} | ; | 11 }}
       | 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 -->
    |<!-- else vardefine -->{{#vardefine:hp | {{#explode: {{#var:row}} | ; | 0 }}
}}<!-- output
    }}{{#vardefine:speed | {{#explode: {{#var:row}} | ; | 1 }}
-->{{#ifeq: {{#var:mode}} | row |
    }}{{#vardefine:atk | {{#explode: {{#var:row}} | ; | 2 }}
  {{#var:name}} {{!}}{{!}} {{#replace: {{#var:row}} | ; | {{!}}{{!}} }} {{!}}{{!}} {{#var:dps}} {{!}}{{!}} {{#var:burst}}
    }}{{#vardefine:atkint | {{#explode: {{#var:row}} | ; | 3 }}
}}{{#ifeq: {{#var:mode}} | param |
    }}{{#vardefine:range | {{#explode: {{#var:row}} | ; | 4 }}
  name = {{#var:name}}
    }}{{#vardefine:splash | {{#explode: {{#var:row}} | ; | 5 }}
  {{!}} hp = {{#var:hp}}
    }}{{#vardefine:target | {{#explode: {{#var:row}} | ; | 6 }}
  {{!}} speed = {{#var:speed}}
    }}{{#vardefine:units | {{#explode: {{#var:row}} | ; | 7 }}
  {{!}} atk = {{#var:atk}}
    }}{{#vardefine:giant | {{#explode: {{#var:row}} | ; | 8 }}
  {{!}} atkint = {{#var:atkint}}
    }}{{#vardefine:mobility | {{#explode: {{#var:row}} | ; | 9 }}
  {{!}} range = {{#var:range}}
    }}{{#vardefine:cost | {{#explode: {{#var:row}} | ; | 10 }}
  {{!}} splash = {{#var:splash}}
    }}{{#vardefine:unlockcost | {{#explode: {{#var:row}} | ; | 11 }}
  {{!}} target = {{#var:target}}
    }}<!-- calculated variables
  {{!}} units = {{#var:units}}
    -->{{#vardefine:burst|{{#ifexpr: ({{#var:atk|0}})<1 | 0 | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} round 0 }} }}
  {{!}} giant = {{#var:giant}}
    }}{{#vardefine:dps|
  {{!}} mobility = {{#var:mobility}}
      {{#ifexpr: ({{#var:atk|0}}) < 1 <!-- if melting damage -->
  {{!}} cost = {{#var:cost}}
        | {{#expr: {{#explode: {{#var:atk|-0}} | - | 1 }} * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
  {{!}} unlockcost = {{#var:unlockcost}}
        | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
  {{!}} dps = {{#var:dps}}
      }}
  {{!}} burst = {{#var:burst}}
    }}<!-- end vardefine -->
}}{{#if: {{{2|}}} | {{#var:{{{2|}}} }} }}
  }}
}}

Revision as of 14:40, 8 June 2023

Error: Unit "UnitData" undefined!