Module:Currency: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
Tag: Manual revert
No edit summary
Line 23:
val = val - (silver * 1000)
end
if (val > 0) then
output = output .. val .. ' [[File:Copper coin.png|link=]]'
end
return output
end

Revision as of 21:40, 6 November 2024

Documentation for this module may be created at Module:Currency/doc

local p = {}

function p.main(frame)
	local args = frame:getParent().args
    local a = args[1] or args.Amount or args.amount or '0'
	return p.parse(a)
end

function p.parse(a)
	val = tonumber(a)
	if val == nil then
		return nil
	end
	local output = ''
	local gold = math.floor(val / 1000000)
	if gold > 0 then
		output = gold .. ' [[File:Gold coin.png|link=]] '
		val = val - (gold * 1000000)
	end
	local silver = math.floor(val / 1000)
	if (silver > 0) or (gold > 0) then
		output = output .. silver .. ' [[File:Silver coin.png|link=]] '
		val = val - (silver * 1000)
	end
	if (val > 0) then
		output = output .. val .. ' [[File:Copper coin.png|link=]]'
	end
	return output
end

return p