Module:MonsterVariantsTable: Difference between revisions

Remove border between image and name
(Fix unlock_level logic for when it's N/A. Use plinkt styling. Align levels to the right.)
(Remove border between image and name)
(One intermediate revision by the same user not shown)
Line 19:
 
function p._main(variant)
local results = mw.smw.ask{
('[[Variant of::%s]]'):format(variant),
'?Image#64px;x64px = img',
'?Name = name',
'?= page',
'?Unlock_level = unlock_lvl',
'?Unlock profession # = unlock_profession',
'?Profession_Level_A = combat',
'?Profession A # = profession',
'?Version default = default',
'?Variant name = variant',
'?Version anchor = version',
'?-Has subobject#- = subobject',
'sort=Profession Level A',
'order=asc'
}
}
mw.logObject(results)
if results == nil or results[1] == nil then
return ":''No variants found for "..variant.."''"
end
 
local filtered = p.filter_versions(results)
local sorted = p.sort_by_combat(filtered)
 
return p.create_table(sorted)
end
 
Line 60:
 
function p.sort_by_combat(data)
table.sort(data, function(a, b)
-- Determine combat values
local combatA = a.combat or a.unlock_lvl or math.huge
local combatB = b.combat or b.unlock_lvl or math.huge
-- Sort in ascending order
return combatA < combatB
end)
return data
end
 
Line 73:
local edit = editbutton("'''?''' (edit)", entry.name)
tbl:tr()
:td{ entry.img, addClass = 'plinkt-image no-border' }:done()
:td{ entry.page, addClass = 'plinkt-link no-border' }:done()
:td()
:IF(entry.unlock_profession)
Line 87:
:done()
:done()
 
return tbl
end
Line 99:
:th('Combat level'):done()
:done()
 
for _, entry in ipairs(results) do
out = p.insert_row(out, entry)
end
 
return out
end
1,483

edits