Template:Number: Difference between revisions

From The Perfect Tower II
Jump to navigation Jump to search
Lmnt0 (talk | contribs)
Created page with "<includeonly>{{#invoke:FormatNumber|main}}</includeonly><noinclude> <templatedata> { "params": { "1": { "label": "Number", "description": "The number to format (in lo..."
 
Lmnt0 (talk | contribs)
update templatedata for icon display
 
(3 intermediate revisions by the same user not shown)
Line 5: Line 5:
"1": {
"1": {
"label": "Number",
"label": "Number",
"description": "The number to format (in long form or scientific notation)",
"description": "The number to display (in long form or scientific notation)",
"example": "1e7",
"example": "10,000,000 or 1e7",
"required": true,
"type": "number",
"type": "number"
"required": true
},
},
"format": {
"format": {
Line 15: Line 15:
"example": "named",
"example": "named",
"type": "string"
"type": "string"
},
"prefix": {
"label": "Prefix",
"description": "Add an optional prefix to the number",
"example": "$",
"type": "string"
},
"suffix": {
"label": "Suffix",
"description": "Add an optional suffix to the number",
"example": "%",
"type": "string"
},
"sortkey": {
"label": "Sort Key",
"description": "Specify a custom sort key to override default table number sorting",
"example": "Z",
"type": "string"
},
"icon": {
"label": "Icon",
"description": "Add an icon (e.g. for resource display)",
"example": "{{Resource|White}}",
"type": "string"
},
"iconpos": {
"label": "Icon Position",
"description": "Position of the icon (if specified), 'left' places it on the left, otherwise defaults to the right",
"example": "left",
"type": "string",
"default": "right"
}
}
},
},
"description": "Show a large number in named and/or scientific notations, matching in-game formatting",
"description": "Display a large number in named and/or scientific notations, matching in-game formatting",
"format": "inline"
"format": "inline"
}
}
</templatedata>
</templatedata>
== Examples ==
{| class="wikitable"
!Input!!Output
|-
|<code><nowiki>{{Number|120000}}</nowiki></code>||{{Number|120000}}
|-
|<code><nowiki>{{Number|18000000000}}</nowiki></code>||{{Number|18000000000}}
|-
|<code><nowiki>{{Number|12456712473}}</nowiki></code>||{{Number|12456712473}}
|-
|<code><nowiki>{{Number|7.4e87}}</nowiki></code>||{{Number|7.4e87}}
|-
|<code><nowiki>{{Number|5E+34|format=named}}</nowiki></code>||{{Number|5E+34|format=named}}
|-
|<code><nowiki>{{Number|3.50e+09|format=scientific}}</nowiki></code>||{{Number|3.50e+09|format=scientific}}
|-
|<code><nowiki>{{Number|3555|prefix=$}}</nowiki></code>||{{Number|3555|prefix=$}}
|-
|<code><nowiki>{{Number|1.8e12|suffix=%}}</nowiki></code>||{{Number|1.8e12|suffix=%}}
|-
|<code><nowiki>{{Number|2e308}}</nowiki></code>||{{Number|2e308}}
|-
|<code><nowiki>{{Number|2e28|icon={{Resource|Blue}}}}</nowiki></code>||{{Number|2e28|icon={{Resource|Blue}}}}
|}
</noinclude>
</noinclude>

Latest revision as of 01:31, 27 March 2021

Display a large number in named and/or scientific notations, matching in-game formatting

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Number1

The number to display (in long form or scientific notation)

Example
10,000,000 or 1e7
Numberrequired
Formatformat

Force a specific format (named or scientific). If blank, displays both named and scientific (preferred)

Example
named
Stringoptional
Prefixprefix

Add an optional prefix to the number

Example
$
Stringoptional
Suffixsuffix

Add an optional suffix to the number

Example
%
Stringoptional
Sort Keysortkey

Specify a custom sort key to override default table number sorting

Example
Z
Stringoptional
Iconicon

Add an icon (e.g. for resource display)

Example
{{Resource|White}}
Stringoptional
Icon Positioniconpos

Position of the icon (if specified), 'left' places it on the left, otherwise defaults to the right

Default
right
Example
left
Stringoptional

Examples

Input Output
{{Number|120000}} 120,000
{{Number|18000000000}} 18 B (1.8e10)
{{Number|12456712473}} 12.457 B (1.246e10)
{{Number|7.4e87}} 7.4 OcV (7.4e87)
{{Number|5E+34|format=named}} 50 De
{{Number|3.50e+09|format=scientific}} 3.5e9
{{Number|3555|prefix=$}} $3,555
{{Number|1.8e12|suffix=%}} 1.8 T% (1.8e12%)
{{Number|2e308}} Infinity
{{Number|2e28|icon={{Resource|Blue}}}} 20 Oc (2e28) Blue resource