Documentation for this module may be created at Module:Icons/doc
local getArgs = require('Module:Arguments').getArgs
local constants = require('Module:Constants')
local data = mw.loadData('Module:Icons/data')
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local icon = args[1]
local size = args['size'] or '30px'
local icons = data.icons
local links = data.links
if icon then
if icons[string.lower(icon)] then
local tmp_icon = string.lower(icon)
return string.format('[[File:%s|x%s|link=%s]]', icons[tmp_icon], size, links[tmp_icon] or '')
-- units
elseif icons[constants.get_unit(icon)] then
return string.format('[[File:%s|x%s|link=%s]]', icons[constants.get_unit(icon)], size, links[icon] or '')
-- rarities
elseif string.find(icon, "^[1-5] star$") or string.find(icon, "^[1-5] star trained$") then
local count = tonumber(string.match(icon, "[1-5]"))
local star_icon = string.match(icon, "star trained") or string.match(icon, "star")
local ret = ''
for i=1,count do
ret = ret .. string.format('[[File:%s|x%s|link=]] ', icons[star_icon], size)
end
return ret
end
end
return nil
end
return p