Module:MonsterVariantsTable: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
Californ1a (talk | contribs) (Created page with "local p = {} function p.main(frame) return p._main(frame:getParent().args) end function p._main(args) local variant = args[1] or args.variant or 'Thug' 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', '?= page', '?Unlock_level = unlock', '?Has subobject.Unlock_level = u...") |
Californ1a (talk | contribs) mNo edit summary |
||
Line 3: | Line 3: | ||
function p.main(frame) |
function p.main(frame) |
||
return p._main(frame:getParent().args) |
return p._main(frame:getParent().args) |
||
end |
|||
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 '?') |
|||
if high then |
|||
level_text = ('%s➨%d'):format(level_text, high) |
|||
end |
|||
return ('%s [[File:%s small icon.png|21x21px|link=%s]]'):format(level_text, profession, profession) |
|||
end |
end |
||
function p._main(args) |
function p._main(args) |
||
local variant = args[1] or args.variant or ' |
local variant = args[1] or args.variant 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), |
||
Line 16: | Line 28: | ||
'?Profession_Level_A = combat', |
'?Profession_Level_A = combat', |
||
'?Has subobject.Profession_Level_A = combat2', |
'?Has subobject.Profession_Level_A = combat2', |
||
'?Profession A #=proffesion', |
|||
'?Has subobject.Profession A #=profession2' |
|||
} |
} |
||
local results = mw.smw.ask(query) |
local results = mw.smw.ask(query) |
||
if results == nil or results[1] == nil then |
|||
return 'No data found for table' |
|||
end |
|||
local sorted = p.sort_by_combat(results) |
local sorted = p.sort_by_combat(results) |
||
local debug_str = '<pre>'..mw.text.jsonEncode(sorted, mw.text.JSON_PRETTY)..'</pre>' |
--local debug_str = '<pre>'..mw.text.jsonEncode(sorted, mw.text.JSON_PRETTY)..'</pre>' |
||
return tostring(p.create_table(sorted))--..debug_str |
return tostring(p.create_table(sorted))--..debug_str |
||
Line 45: | Line 64: | ||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:wikitext(entry.unlock) |
:wikitext(p.formatProfessionLevel(entry.profession, entry.unlock)) |
||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:wikitext(entry.combat) |
:wikitext(p.formatProfessionLevel(entry.profession, entry.combat)) |
||
:done() |
:done() |
||
:done() |
:done() |
||
Line 78: | Line 97: | ||
img = entry.img or entry.img2[1] or entry.img2 or '', |
img = entry.img or entry.img2[1] or entry.img2 or '', |
||
unlock = entry.unlock or entry.unlock2[1] or entry.unlock2 or '', |
unlock = entry.unlock or entry.unlock2[1] or entry.unlock2 or '', |
||
profession = entry.profession or entry.profession2[1] or entry.profession2 or '', |
|||
page = entry.page |
page = entry.page |
||
} |
} |