Module:CoinDisplay: Difference between revisions

From IdleOn MMO Wiki
(Created page with "local p = {} function p.Main(frame) local n = tonumber(frame.args.coins) local ret = {} local coins = {"Copper", "Silver", "Gold", "Platinum", "Dementia", "Void", "Lustre", "Starfire", "Dreadlo", "Godshard", "Sunder", "Tydal", "Marbiglass", "Orberal", "Eclipse"} local coininc = 1 local stringpiece = [=[link= %s]=] repeat -- Set denomVStr to remaining n if on last type, or get last 2 for current denom. local denomV = n if coininc < #co...")
 
mNo edit summary
Tag: Reverted
Line 12: Line 12:
local denomV = n
local denomV = n
if coininc < #coins then
if coininc < #coins then
denomV = denomV % 100
denomV = floor(denomV / 100)
end
end
if denomV > 0 then
if denomV > 0 then
Line 18: Line 18:
end
end
if coininc < #coins then
if coininc < #coins then
n = math.floor(n / 100)
n = n % 100
else
else
n = 0
n = 0

Revision as of 07:08, 10 March 2024

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

local p = {}

function p.Main(frame)
	local n = tonumber(frame.args.coins)
	local ret = {}
	local coins = {"Copper", "Silver", "Gold", "Platinum", "Dementia", "Void", "Lustre", "Starfire", "Dreadlo", "Godshard", "Sunder", "Tydal", "Marbiglass", "Orberal", "Eclipse"} 
	local coininc = 1
	local stringpiece = [=[[[File:%s Coin.png|link=]] %s]=]
	
	repeat
		-- Set denomVStr to remaining n if on last type, or get last 2 for current denom.
		local denomV = n
		if coininc < #coins then
			denomV = floor(denomV / 100)
		end
		if denomV > 0 then
			ret[#ret+1] = string.format(stringpiece, coins[coininc], tostring(denomV))
		end	
		if coininc < #coins then
			n = n % 100
		else
			n = 0
		end
		coininc = coininc + 1
	until(n == 0)
	
	return table.concat(ret, " ")
end

return p