Template:Coppercost/doc

This template takes a money value as one parameter, representing the value in copper, and calls the template to show the amount as gold, silver and copper.

Useful to represent amounts of money which are calculated, e.g. with the parserfunction #expr:.

The inverse of this template is costcopper, most commonly referenced using its sell alias.

Syntax
amount

amount is an amount of money, expressed as the number of copper coins. Gold, silver or copper coin numbers are only shown if they are not zero.

If amount is zero, the result is.

Source code explained
1
 * 1) Call the template.
 * 2) Start the gold parameter. Only fill in if there is a valid amount parameter.
 * 3) Test if the amount is equal to zero or is big enough to get gold (100*100=10000 copper per gold).
 * 4) If so, then put the value in: amount div 10000. Note: the div operator does not appear to do what it says on the tin, so we have to make do with a normal division rounded down.
 * 5) Close the #ifexpr
 * 6) Close the #if
 * 7) Start the silver parameter. Only show if the amount of silver is more than zero.
 * 8) The expression calculates the amount (0-99) of silver coins. It is essentially is ( amount mod 10000) div 100.
 * 9) True clause of the #ifexpr. Fill in the silver amount. The expression is the same as the one on the previous line.
 * 10) Close the #ifexpr
 * 11) Start the copper parameter. Only show if the amount of copper is more than zero.
 * 12) The expression calculates the amount (0-99) of copper coins, amount mod 100.
 * 13) True clause of the #ifexpr. Fill in the copper amount. This is the same expression as on the previous line.
 * 14) Close the #ifexpr
 * 15) Close the Cost template

ru:Шаблон:ЦенаМедные