Editing Module:Currency
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 15: | Line 15: | ||
-- Initialize output string |
-- Initialize output string |
||
local output = '' |
local output = '' |
||
local isNegative = val < 0 |
|||
local prefix = "" |
|||
if isNegative then |
|||
val = -val |
|||
prefix = "-" |
|||
end |
|||
-- Calculate gold, silver, and copper values |
-- Calculate gold, silver, and copper values |
||
local gold = math. |
local gold = math.floor(val / 1000000) |
||
local silver = math. |
local silver = math.floor((val % 1000000) / 1000) |
||
local copper = val % 1000 |
local copper = val % 1000 |
||
-- Append gold if present |
-- Append gold if present |
||
if gold > 0 then |
if gold > 0 then |
||
output = |
output = output .. gold .. ' [[File:Gold coin.png|link=]] ' |
||
end |
end |
||
-- Append silver if present |
-- Append silver if present |
||
if silver > 0 then |
if silver > 0 then |
||
output = output |
output = output .. silver .. ' [[File:Silver coin.png|link=]] ' |
||
end |
end |
||
-- Append copper if present or if total value is exactly 0 |
-- Append copper if present or if total value is exactly 0 |
||
if copper > 0 or val == 0 then |
if copper > 0 or val == 0 then |
||
output = output |
output = output .. copper .. ' [[File:Copper coin.png|link=]]' |
||
end |
end |
||