Module:Alz

-- -- Implements -- Original source: http://runescape.wiki/w/Module:Coins?action=history

local p = {}

local function amount(a) -- convert used globals to locals where possible to improve performance local math = math local string = string local table = table local mw = mw       local expr = mw.ext.ParserFunctions.expr

local ret = {true, true, true, true, ' ', ' Alz'}

--Initial tag. ret[1] = ' '1,000' a = string.gsub(a, ',', '')

-- for performance reasons, only calculate expr if required local a2 = tonumber(a) if a2 == nil then a = expr(a) a2 = tonumber(a) or 0 end

-- round to 2 d.p.	a = math.floor(a2 * 100 + 0.5) / 100

-- If we want any class add it in here. ret[2] = 'class=""'

-- set a class to denote positive or negative (css sets the colour) if a < 0 then ret[3] = ' style="color: red;">' elseif a < 100000 then ret[3] = ' style="color: white;">' elseif a < 1000000 then ret[3] = ' style="color: #FFEA8A;">' elseif a < 10000000 then ret[3] = ' style="color: cyan;">' elseif a < 100000000 then ret[3] = ' style="color: orange;">' elseif a < 1000000000 then ret[3] = ' style="color: cornflowerblue;">' else ret[3] = ' style="color: palegreen;">' end

-- format number with commas ret[4] = mw.language.getContentLanguage:formatNum(a)

return table.concat( ret ) end

-- -- access point -- function p.amount(frame) local args = frame:getParent.args -- for local a = args[1] or '0' return amount(a) end

-- -- Module access point -- function p._amount(a) a = tostring(a) or '0' return amount(a) end

return p