Home
Random
Log in
Settings
About Brighter Shores Wiki
Disclaimers
Search
Editing
Module:MonsterVariantsTable
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local editbutton = require('Module:Edit button') local p = {} function p.main(frame) return p._main(frame:getParent().args) end function p.formatProfessionLevel(profession, level, high) 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 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', '?Has subobject.Unlock_level = unlock2', '?Profession_Level_A = combat', '?Has subobject.Profession_Level_A = combat2', '?Profession A #=profession', '?Has subobject.Profession A #=profession2' } local results = mw.smw.ask(query) if results == nil or results[1] == nil then return ":''No variants found for "..variant.."''" end local sorted = p.sort_by_combat(results) --local debug_str = '<pre>'..mw.text.jsonEncode(sorted, mw.text.JSON_PRETTY)..'</pre>' return tostring(p.create_table(sorted))--..debug_str end function p.sort_by_combat(data) table.sort(data, function(a, b) -- Determine combat values local combatA = a.combat or (a.combat2 and a.combat2[1]) or math.huge local combatB = b.combat or (b.combat2 and b.combat2[1]) or math.huge -- Sort in ascending order return combatA < combatB end) return data end function p.insert_row(tbl, entry) tbl:tag('tr') :tag('td') :wikitext(entry.img) :done() :tag('td') :wikitext(entry.page) :done() :tag('td') :wikitext(p.formatProfessionLevel(entry.profession, entry.unlock)) :done() :tag('td') :wikitext(p.formatProfessionLevel(entry.profession, entry.combat)) :done() :done() 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 function p.create_table(results) local out = mw.html.create('table') :addClass('wikitable sortable') :tag('tr') :tag('th') :wikitext('Image') :done() :tag('th') :wikitext('Monster') :done() :tag('th') :wikitext('Unlocked at') :done() :tag('th') :wikitext('Combat level') :done() :done() for _,entry in ipairs(results) do local edit = editbutton("'''?''' (edit)", entry.name) local built_entry = { combat = p.get_entry(entry, 'combat') or edit, img = p.get_entry(entry, 'img') or mw.ustring.format('[[File:%s.png|64px|x64px]]', entry.name), unlock = p.get_entry(entry, 'unlock') or edit, profession = p.get_entry(entry, 'profession') or nil, page = entry.page } out = p.insert_row(out, built_entry) end return out end return p
Summary:
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see
Brighter Shores:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Templates used on this page:
Template:DependencyList
(
edit
)
Template:Documentation
(
edit
)
Template:Extension DPL
(
edit
)
Template:MonsterVariantsTable
(
edit
)
Template:MonsterVariantsTable/doc
(
edit
)
Template:No documentation
(
edit
)
Template:PageType
(
edit
)
Module:Array
(
edit
)
Module:DPLlua
(
edit
)
Module:DependencyList
(
edit
)
Module:Documentation
(
edit
)
Module:MonsterVariantsTable
(
edit
)
Module:MonsterVariantsTable/doc
(
edit
)
Module:Paramtest
(
edit
)
Module:Tooltip
(
edit
)
Module:Yesno
(
view source
) (semi-protected)
This page is a member of a hidden category:
Category:Pages using DynamicPageList3 parser function