Content added Content deleted
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
function p._main(args) |
function p._main(args) |
||
local rarity = |
local rarity = nil |
||
local size = |
local size = '30px' |
||
local trained = yesno(args['trained'], false) |
|||
local icons = data |
local icons = data |
||
⚫ | |||
for _, val in ipairs(args) do |
|||
⚫ | |||
if string.find(val, "^[1-5]$") or |
|||
string.find(val, "^[1-5] trained$") or |
|||
elseif rarityNum and rarityNum >= 1 and rarityNum <= 5 then |
|||
string.lower(val) == 'birthday' then |
|||
⚫ | |||
rarity = string.lower(val) |
|||
elseif string.find(val, "^%d+px$") then |
|||
⚫ | |||
size = val |
|||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
if rarity == nil then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
return string.format('[[File:%s|x%s|link=]]', icons['birthday'], size) |
|||
end |
|||
⚫ | |||
local trained = string.match(rarity, "trained") |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
return table.concat(ret, ' ') |
|||
end |
end |
||
Latest revision as of 03:56, 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 = nil
local size = '30px'
local icons = data
for _, val in ipairs(args) do
if string.find(val, "^[1-5]$") or
string.find(val, "^[1-5] trained$") or
string.lower(val) == 'birthday' then
rarity = string.lower(val)
elseif string.find(val, "^%d+px$") then
size = val
end
end
if rarity == nil then
return nil
end
if rarity == 'birthday' then
return string.format('[[File:%s|x%s|link=]]', icons['birthday'], size)
end
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 p