Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
Currency: Implement for currency templates; _Currency: Add category to output for non-numeric amount arguments
(Use class in place of inline styles)
(Currency: Implement for currency templates; _Currency: Add category to output for non-numeric amount arguments)
Line 877: Line 877:
end
end
table.insert(ret, '</span>')
table.insert(ret, '</span>')
if ((amount ~= nil and tonumber(amount) == nil)
or (maxAmount ~= nil and tonumber(maxAmount) == nil)) then
table.insert(ret, '[[Category:Pages with non-numeric currency arguments]]')
end
return table.concat(ret)
return table.concat(ret)
Line 891: Line 896:
function p.RC(amt, maxamt)
function p.RC(amt, maxamt)
return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', 'RC', amt, maxamt)
return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', 'RC', amt, maxamt)
end
-- p.Currency() is called by various currency templates:
-- [[Template:GP]], [[Template:SC]], [[Template:RC]]
function p.Currency(frame)
local args = frame.args ~= nil and frame.args or frame
local currID, minVal, maxVal, _
currID = args[1]
if args[2] ~= nil then
minVal, _ = string.gsub(args[2], ',', '')
end
if args[3] ~= nil then
maxVal, _ = string.gsub(args[3], ',', '')
end
if currID == 'GP' then
return p.GP(minVal, maxVal)
elseif currID == 'SC' then
return p.SC(minVal, maxVal)
elseif currID == 'RC' then
return p.RC(minVal, maxVal)
else
return Shared.printError('Invalid currency: ' .. (currID == nil and 'nil' or currID))
end
end
end