Module:MonsterVariantsTable: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
(One intermediate revision by the same user not shown)
Line 1:
local editbutton = require('Module:Edit button')
local p = {}
 
Line 6 ⟶ 7:
 
function p.formatProfessionLevel(profession, level, high)
if not (profession or level) then
return nil
end
profession = profession or 'Unknown profession'
local level_text = tostring(level or '?')
Line 17 ⟶ 15:
end
 
function p._main(args, Avariant)
local variant = args[1] or args.variant or Avariant or ''
local query = {
string.format('[[Variant of::%s]] [[Has query::+]] OR [[Has subobject::<q>[[Variant of::%s]]</q>]]', variant, variant),
'?Image#64px;x64px=img',
'?Has subobject.Image#64px;x64px=img2',
'?Name=name',
'?= page',
'?Unlock_level = unlock',
Line 35 ⟶ 34:
if results == nil or results[1] == nil then
return ":''No datavariants found for table"..variant.."''"
end
Line 72 ⟶ 71:
return tbl
end
 
function p.get_entry(entry, param)
return entry[param]
or (type(entry[param..'2']) == 'table' and entry[param..'2'][1])
or (type(entry[param..'2']) == 'string' and entry[param..'2'])
end
 
Line 93 ⟶ 98:
for _,entry in ipairs(results) do
local edit = editbutton("'''?''' (edit)", entry.name)
local built_entry = {
combat = entryp.combat or get_entry(entry.combat2[1], or entry.combat2'combat') or ''edit,
img = entryp.get_entry(entry, 'img') or entrymw.img2ustring.format('[1[File:%s.png|64px|x64px] or]', entry.img2 or ''name),
unlock = entryp.unlock or get_entry(entry.unlock2[1], or entry.unlock2'unlock') or ''edit,
profession = entryp.profession or get_entry(entry.profession2[1], or entry.profession2'profession') or ''nil,
page = entry.page
}
7,248

edits