Module:CollectionLog: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Manual revert |
No edit summary Tag: Reverted |
||
Line 3: | Line 3: | ||
function p.render(frame) | function p.render(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local html = mw.html.create('div'):addClass('collection-log-grid') | local html = mw.html.create('div'):addClass('collection-log-wrapper') | ||
-- Show Killcount if provided | |||
if args.Killcount then | |||
local kcDiv = mw.html.create('div') | |||
:addClass('collection-log-killcount') | |||
:wikitext(string.format('Killcount: <b>%s</b>', args.Killcount)) | |||
html:node(kcDiv) | |||
end | |||
local grid = mw.html.create('div'):addClass('collection-log-grid') | |||
-- Define fixed order to keep consistent display order | |||
local order = { | |||
"Tanzanite_fang", | |||
"Serpentine_visage", | |||
"Magic_fang", | |||
"Uncut_onyx" | |||
} | |||
for _, name in ipairs(order) do | |||
local qty = tonumber(args[name]) or 0 | |||
local obtainedClass = qty > 0 and 'obtained' or 'missing' | |||
local item = mw.html.create('div') | local item = mw.html.create('div') | ||
:addClass('collection-log-item') | :addClass('collection-log-item') | ||
:addClass( | :addClass(obtainedClass) | ||
-- Build image with optional quantity overlay | |||
'[[File:%s.png|32x32px | local img = string.format( | ||
name, name, name | '[[%s|[[File:%s.png|32x32px|alt=%s|title=%s]]]]', | ||
name, name, name, name | |||
) | |||
html:node(item) | item:wikitext(img) | ||
if qty > 1 then | |||
-- Add quantity badge | |||
local badge = mw.html.create('div') | |||
:addClass('collection-log-qty-badge') | |||
:wikitext(qty) | |||
item:node(badge) | |||
end | |||
grid:node(item) | |||
end | end | ||
html:node(grid) | |||
return tostring(html) | return tostring(html) |
Revision as of 06:30, 19 May 2025
Documentation for this module may be created at Module:CollectionLog/doc
local p = {}
function p.render(frame)
local args = frame:getParent().args
local html = mw.html.create('div'):addClass('collection-log-wrapper')
-- Show Killcount if provided
if args.Killcount then
local kcDiv = mw.html.create('div')
:addClass('collection-log-killcount')
:wikitext(string.format('Killcount: <b>%s</b>', args.Killcount))
html:node(kcDiv)
end
local grid = mw.html.create('div'):addClass('collection-log-grid')
-- Define fixed order to keep consistent display order
local order = {
"Tanzanite_fang",
"Serpentine_visage",
"Magic_fang",
"Uncut_onyx"
}
for _, name in ipairs(order) do
local qty = tonumber(args[name]) or 0
local obtainedClass = qty > 0 and 'obtained' or 'missing'
local item = mw.html.create('div')
:addClass('collection-log-item')
:addClass(obtainedClass)
-- Build image with optional quantity overlay
local img = string.format(
'[[%s|[[File:%s.png|32x32px|alt=%s|title=%s]]]]',
name, name, name, name
)
item:wikitext(img)
if qty > 1 then
-- Add quantity badge
local badge = mw.html.create('div')
:addClass('collection-log-qty-badge')
:wikitext(qty)
item:node(badge)
end
grid:node(item)
end
html:node(grid)
return tostring(html)
end
return p