Module:MonsterVariantsTable: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
Californ1a (talk | contribs) mNo edit summary |
Californ1a (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
local editbutton = require('Module:Edit button') |
|||
local p = {} |
local p = {} |
||
Line 6: | Line 7: | ||
function p.formatProfessionLevel(profession, level, high) |
function p.formatProfessionLevel(profession, level, high) |
||
if not (profession or level) then |
|||
return nil |
|||
⚫ | |||
profession = profession or 'Unknown profession' |
profession = profession or 'Unknown profession' |
||
local level_text = tostring(level or '?') |
local level_text = tostring(level or '?') |
||
Line 17: | Line 15: | ||
end |
end |
||
function p._main(args) |
function p._main(args, Avariant) |
||
local variant = args[1] or args.variant or '' |
local variant = args[1] or args.variant or Avariant or '' |
||
local query = { |
local query = { |
||
string.format('[[Variant of::%s]] [[Has query::+]] OR [[Has subobject::<q>[[Variant of::%s]]</q>]]', variant, variant), |
string.format('[[Variant of::%s]] [[Has query::+]] OR [[Has subobject::<q>[[Variant of::%s]]</q>]]', variant, variant), |
||
'?Image#64px;x64px=img', |
'?Image#64px;x64px=img', |
||
'?Has subobject.Image#64px;x64px=img2', |
'?Has subobject.Image#64px;x64px=img2', |
||
'?Name=name', |
|||
'?= page', |
'?= page', |
||
'?Unlock_level = unlock', |
'?Unlock_level = unlock', |
||
Line 72: | Line 71: | ||
return tbl |
return tbl |
||
⚫ | |||
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 |
end |
||
Line 93: | Line 98: | ||
for _,entry in ipairs(results) do |
for _,entry in ipairs(results) do |
||
local edit = editbutton("'''?''' (edit)", entry.name) |
|||
local built_entry = { |
local built_entry = { |
||
combat = |
combat = p.get_entry(entry, 'combat') or edit, |
||
img = |
img = p.get_entry(entry, 'img') or mw.ustring.format('[[File:%s.png|64px|x64px]]', entry.name), |
||
unlock = |
unlock = p.get_entry(entry, 'unlock') or edit, |
||
profession = |
profession = p.get_entry(entry, 'profession') or nil, |
||
page = entry.page |
page = entry.page |
||
} |
} |