Module:MonsterVariantsTable: Difference between revisions
Remove border between image and name
Californ1a (talk | contribs) m (cleanup) |
(Remove border between image and name) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1:
require('strict')
require('Module:Mw.html extension')
local editbutton = require('Module:Edit button')
local p = {}
function p.main(frame)
return p._main(args[1] or args.variant or '')
end
local function
profession = profession or 'Unknown profession'
local level_text = tostring(level or '?')
Line 15 ⟶ 18:
end
function p._main(
local
▲ string.format('[[Variant of::%s]]', variant),
'?Name = name',
▲ '?Image#64px;x64px = img',
'?Unlock profession # = unlock_profession',
▲ '?Unlock_level = unlock',
}▼
if results == nil
▲ mw.logObject(results)
return ":''No variants found for "..variant.."''"
end
local filtered = p.filter_versions(results)▼
local sorted = p.sort_by_combat(filtered)▼
return tostring(p.create_table(sorted))▼
end
function p.filter_versions(data)
local filtered = {}
for _, entry in ipairs(data) do
if entry.default
entry.page = ('[[%s|%s]]'):format(entry.subobject, entry.name)
table.insert(filtered, entry)
Line 59 ⟶ 60:
function p.sort_by_combat(data)
end
function p.insert_row(tbl, entry)
local edit = editbutton("'''?''' (edit)", entry.name)
tbl:
:td{ entry.img, addClass = 'plinkt-image no-border' }:done()
:tag('td')▼
:td{ entry.page, addClass = 'plinkt-link no-border' }:done()
:wikitext(entry.img)▼
:IF(entry.unlock_profession)
:wikitext(entry.
:addClass('table-na')
:done()
:
:wikitext(entry.
▲ :wikitext(entry.unlock and p.formatProfessionLevel(entry.profession, entry.unlock) or edit)
:done()
:done()
return tbl
end
Line 91 ⟶ 93:
function p.create_table(results)
local out = mw.html.create('table')
:addClass('wikitable sortable align-right-3 align-right-4')
:
:th{ 'Monster', attr = { colspan = 2 } }:done()
:th('Combat level'):done()
▲ :done()
▲ :done()
:done()
for _, entry in ipairs(results) do
out = p.insert_row(out, entry)
end
return out
end
|