Template:GetLevelRange: Difference between revisions
From HorizonXI Wiki
(added check if input is an integer to return unkown if not) |
m (added 0 as special case) |
||
Line 1: | Line 1: | ||
<includeonly><onlyinclude>{{#if:{{{1|}}}|{{#iferror:{{#expr:{{{1}}}}}|Unknown|{{#ifexpr:{{{1}}}<=10|1-10|<!-- | <includeonly><onlyinclude>{{#if:{{{1|}}}|{{#iferror:{{#expr:{{{1}}}}}|Unknown|{{#ifeq:{{{1}}}|0|0|{{#ifexpr:{{{1}}}<=10|1-10|<!-- | ||
-->{{#expr:trunc(({{{1|}}}-1)/10)}}1-{{#expr:1+(trunc(({{{1|}}}-1)/10))}}0<!-- | -->{{#expr:trunc(({{{1|}}}-1)/10)}}1-{{#expr:1+(trunc(({{{1|}}}-1)/10))}}0<!-- | ||
-->}}<!-- | -->}}}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->|Unknown}}</onlyinclude></includeonly> | -->|Unknown}}</onlyinclude></includeonly> | ||
==Usage== | ==Usage== | ||
Takes a number as argument and returns the 10s level range it belongs to. | Takes a number as argument and returns the 10s level range it belongs to. | ||
Line 28: | Line 27: | ||
<pre>{{GetLevelRange|142}}</pre> | <pre>{{GetLevelRange|142}}</pre> | ||
{{GetLevelRange|142}} | {{GetLevelRange|142}} | ||
Treats 0 as a special case as needed for e.g. event items, and will return 0. | |||
<pre>{{GetLevelRange|0}}</pre> | |||
{{GetLevelRange|0}} | |||
Returns ''Unknown'' if the input is not an integer... | Returns ''Unknown'' if the input is not an integer... |
Latest revision as of 20:27, 4 September 2024
Usage
Takes a number as argument and returns the 10s level range it belongs to.
{{GetLevelRange|15}}
11-20
{{GetLevelRange|4}}
1-10
{{GetLevelRange|50}}
41-50
{{GetLevelRange|88}}
81-90
{{GetLevelRange|106}}
101-110
Works for any integer number
{{GetLevelRange|142}}
141-150
Treats 0 as a special case as needed for e.g. event items, and will return 0.
{{GetLevelRange|0}}
0
Returns Unknown if the input is not an integer...
{{GetLevelRange|foo}}
Unknown
...or the parameter is left empty...
{{GetLevelRange|}}
Unknown
...or left out
{{GetLevelRange}}
Unknown