# Dota 2 Wiki

3,964

Template:Calculate的文檔 [ 查看 | 編輯 | 淨化 ]

Swapsies!
This template uses Lua.
Its code can be found under 模塊:Calculate.

## Usage

Use this template when calculating with one or more values in the form of a sequence (e.g. 1/2/3).

{{Calculate|expr.|v1=|...|vn=|percent}}
• expr. – The intended calculation in the form of a mathematical expression, with v1...vn representing the respective value sequences, e.g. v1+v2. Supports percentages, e.g. v1*50%, which is automatically converted to v1*0.5. Follows the same rules as the parser function #expr.
• v1,...,vn – Each sequence of values has to be set as a separate parameter vn, with n representing its index number, e.g. v1=1/2/3. Supports percentages, e.g. v1=1%/2%/3%.
• percent – Optional. Can be set to % in order to return the results as percentages.

## Examples

1. {{Calculate|v1+5|v1=1/2/3}}
generates: 6/7/8.
2. {{Calculate|v1*v2|v1=10/15/20/25|v2=0.25/0.5/0.75/1}}
generates: 2.5/7.5/15/25.
3. {{Calculate|v1/3 round2|v1=2/4}}
generates: 0.67/1.33.
4. {{Calculate|v1*80|v1=40%/70%/100%}}
generates: 32/56/80.
5. {{Calculate|v1-v2|%|v1=100%/150%/200%/250%|v2=50%/75%/100%/125%}}
generates: 50%/75%/100%/125%.
6. {{Calculate|(v1-0.3)/5*0.1|v1=1.75/2.5/3.25/4}}
generates: 0.029/0.044/0.059/0.074.
7. {{Calculate|(v1-1)*12%|%|v1=125%/175%/225%/275%}}
generates: 3%/9%/15%/21%.

## TemplateData

Use this template when calculating with one or more values in the form of a sequence.

Calculation1

The calculation with v1, v2, ... in place of the levelled values.

v1+3

Value 1v1

A levelled value with levels separated by a forward slash.

1/2/3/4

Value 2v2

A levelled value with levels separated by a forward slash.

1/2/3/4

Percentage2

Set this parameter to activate sprecial percentage handling.