Template:Coin

From Terraria Wiki
Jump to: navigation, search
Template-info.svg Documentation The documentation below is transcluded from Template:Coin/doc. (edit | history)

Template for showing prices.

Usage[edit source]

There are 2 API styles:

Style A:

{{coin|<pc>|<gc>|<sc>|<cc>}}

{{coin|<gc>|<sc>|<cc>}}

{{coin|<sc>|<cc>}}

{{coin|<cc>}}

e.g. {{coin|1|0|30}} means 1 Gold 30 Copper.

Style B:

{{coin|<number>pc<number>gc<number>sc<number>cc}} all are optional.

e.g. {{coin|1.25gc}} means 1 Gold 25 Silver. e.g. {{coin|1gc30cc}} means 1 Gold 30 Silver.


Other parameters:

round rounded digits, default is 2.

Examples[edit source]

code result
{{coin|30}} 30*30 Copper Coin.png
{{coin|1|30}} 130*1 Silver Coin.png 30 Copper Coin.png
{{coin|1|1}} 101*1 Silver Coin.png 1 Copper Coin.png
{{coin|1sc}} 100*1 Silver Coin.png
{{coin|10gc}} 100000*10 Gold Coin.png
{{coin|100000cc}} 100000*10 Gold Coin.png
{{coin|100000}} 100000*10 Gold Coin.png
{{coin|3|1|30}} 30130*3 Gold Coin.png 1 Silver Coin.png 30 Copper Coin.png
{{coin|3|0|1|30}} 3000130*3 Platinum Coin.png 1 Silver Coin.png 30 Copper Coin.png
{{coin|0|1|0|30}} 10030*1 Gold Coin.png 30 Copper Coin.png
{{coin|1.30gc}} 13000*1 Gold Coin.png 30 Silver Coin.png
{{coin|12 gc 80cc}} 120080*12 Gold Coin.png 80 Copper Coin.png
{{coin|12cc 80gc}} 800012*80 Gold Coin.png 12 Copper Coin.png
{{coin|130 SC}} 13000*1 Gold Coin.png 30 Silver Coin.png
{{coin|1.5gc130sc}} 28000*2 Gold Coin.png 80 Silver Coin.png
{{coin|1.0130gC}} 10130*1 Gold Coin.png 1 Silver Coin.png 30 Copper Coin.png
{{coin|1456.30975 Gc}} 14563097.5*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97.5 Copper Coin.png
{{coin|1456.30975Gc|round=0}} 14563097*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97 Copper Coin.png
{{coin|1456.30975Gc|round=10}} 14563097.5*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97.4999999977 Copper Coin.png
{{coin|14563097.5cc|round=5}} 14563097.5*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97.5 Copper Coin.png

Note[edit source]

  • This template is table sorting friendly(need data-sort-type="number" in header). See example table above, or here.
  • It is only designed for positive numbers, input negative values may result in unexpected results.
  • Due to the internal binary representation, decimal fractions sometimes have minor inaccuracies, e.g {{coin|1456.30975Gc|round=10}} will get 14563097.5*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97.4999999977 Copper Coin.png. This may sometime lead to unexpected result when rounding, e.g {{coin|1456.30975Gc|round=0}} will get 14563097*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97 Copper Coin.png (expected 14563098*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 98 Copper Coin.png). Switching to smaller units can improve this problem, for example: {{coin|145630.975sc|round=10}} will get 14563097.5*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 97.5 Copper Coin.png and {{coin|145630.975sc|round=0}} will get 14563098*14 Platinum Coin.png 56 Gold Coin.png 30 Silver Coin.png 98 Copper Coin.png.