Extension:Variables/Example

From Gamepedia Help Wiki
Jump to: navigation, search

Example 1[edit | edit source]

Variables can be given a default value before their definition.

{{#vardefine:n|{{#expr:{{#var:k|0}}+1}}}}

Now {{#var:n}} = 1

Otherwise you may get an error or otherwise unexpected result:

{{#vardefine:n|{{#expr:{{#var:k}}*1}}}}

Now {{#var:n}} = Expression error: Unexpected * operator.

Example 2[edit | edit source]

{{#vardefine:a|7}}{{#vardefine:b|11}}
{{#vardefine:x|{{#expr:2*{{#var:a}}+{{#var:b}}}} }}

Now {{#var:x}} = 25