Module:CollectionLog
Documentation for this module may be created at Module:CollectionLog/doc
local p = {}
function p.render(frame)
local args = frame:getParent():getArguments()
local html = mw.html.create('div'):addClass('collection-log-wrapper')
-- Look for Killcount first (optional)
local killcount
for _, arg in ipairs(args) do
if arg.name == "Killcount" then
killcount = arg.value
break
end
end
if killcount then
local killcountDiv = mw.html.create('div')
:addClass('collection-log-killcount')
:wikitext('Killcount: ' .. killcount)
html:node(killcountDiv)
end
local grid = mw.html.create('div'):addClass('collection-log-grid')
for _, arg in ipairs(args) do
local name = arg.name
if name ~= "Killcount" then
local qty = tonumber(arg.value) or 0
local item = mw.html.create('div')
:addClass('collection-log-item')
:addClass(qty > 0 and 'obtained' or 'missing')
-- Call your custom template, for example plinkp3
item:wikitext(string.format(
'{{plinkp3|name=%s|qty=%d|obtained=%s}}',
name, qty, qty > 0 and 'obtained' or 'missing'
))
grid:node(item)
end
end
html:node(grid)
return tostring(html)
end
return p