Content added Content deleted
No edit summary |
mNo edit summary |
||
Line 45: | Line 45: | ||
table.insert(ret, string.format('[[File:%s|x%s|link=]]', starIcon, size)) |
table.insert(ret, string.format('[[File:%s|x%s|link=]]', starIcon, size)) |
||
end |
end |
||
return table. |
return table.concat(ret, ' ') |
||
end |
end |
||
Revision as of 03:36, 22 January 2022
Documentation for this module may be created at Module:Rarity icon/doc
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local data = mw.loadData('Module:Rarity icon/data')
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local rarity = string.lower(args[1] or '')
local size = args['size'] or '30px'
local trained = yesno(args['trained'], false)
local icons = data
if rarity == 'birthday' then
return string.format('[[File:%s|x%s]]', icons['birthday'], size)
elseif rarityNum and rarityNum >= 1 and rarityNum <= 5 then
local starIcon = icons['star']
if trained then
starIcon = icons['star trained']
end
local ret = ''
for i=1,rarityNum do
ret = ret .. string.format('[[File:%s|x%s]] ', starIcon, size)
end
return ret
elseif string.find(rarity, "^[1-5]$") or string.find(rarity, "^[1-5] trained$") then
local count = tonumber(string.match(rarity, "[1-5]"))
local trained = string.match(rarity, "trained")
local starIcon = icons['star']
if trained then
starIcon = icons['star trained']
end
local ret = {}
for i=1,count do
table.insert(ret, string.format('[[File:%s|x%s|link=]]', starIcon, size))
end
return table.concat(ret, ' ')
end
return nil
end
return p