Editing Module:MonsterVariantsTable

Jump to navigation Jump to search
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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 19: Line 19:


function p._main(variant)
function p._main(variant)
local results = mw.smw.ask{
local results = mw.smw.ask{
('[[Variant of::%s]]'):format(variant),
('[[Variant of::%s]]'):format(variant),
'?Image#64px;x64px = img',
'?Image#64px;x64px = img',
'?Name = name',
'?Name = name',
'?= page',
'?= page',
'?Unlock_level = unlock_lvl',
'?Unlock_level = unlock_lvl',
'?Unlock profession # = unlock_profession',
'?Unlock profession # = unlock_profession',
'?Profession_Level_A = combat',
'?Profession_Level_A = combat',
'?Profession A # = profession',
'?Profession A # = profession',
'?Version default = default',
'?Version default = default',
'?Variant name = variant',
'?Variant name = variant',
'?Version anchor = version',
'?Version anchor = version',
'?-Version subobject#- = superobject',
'?-Has subobject#- = subobject',
'sort=Profession Level A',
'sort=Profession Level A',
'order=asc'
'order=asc'
}
}
mw.logObject(results)
mw.logObject(results)
if results == nil or results[1] == nil then
if results == nil or results[1] == nil then
return ":''No variants found for "..variant.."''"
return ":''No variants found for "..variant.."''"
end
end


local filtered = p.filter_versions(results)
local filtered = p.filter_versions(results)
local sorted = p.sort_by_combat(filtered)
local sorted = p.sort_by_combat(filtered)


return p.create_table(sorted)
return p.create_table(sorted)
end
end


Line 50: Line 50:
for _, entry in ipairs(data) do
for _, entry in ipairs(data) do
if entry.default then
if entry.default then
entry.page = ('[[%s|%s]]'):format(entry.superobject, entry.name)
entry.page = ('[[%s|%s]]'):format(entry.subobject, entry.name)
table.insert(filtered, entry)
table.insert(filtered, entry)
elseif entry.version == nil then
elseif entry.version == nil then
Line 60: Line 60:


function p.sort_by_combat(data)
function p.sort_by_combat(data)
table.sort(data, function(a, b)
table.sort(data, function(a, b)
-- Determine combat values
-- Determine combat values
local combatA = a.combat or a.unlock_lvl or math.huge
local combatA = a.combat or a.unlock_lvl or math.huge
local combatB = b.combat or b.unlock_lvl or math.huge
local combatB = b.combat or b.unlock_lvl or math.huge
-- Sort in ascending order
-- Sort in ascending order
return combatA < combatB
return combatA < combatB
end)
end)
return data
return data
end
end


Line 73: Line 73:
local edit = editbutton("'''?''' (edit)", entry.name)
local edit = editbutton("'''?''' (edit)", entry.name)
tbl:tr()
tbl:tr()
:td{ entry.img, addClass = 'plinkt-image no-border' }:done()
:td{ entry.img, addClass = 'plinkt-image' }:done()
:td{ entry.page, addClass = 'plinkt-link no-border' }:done()
:td{ entry.page, addClass = 'plinkt-link' }:done()
:td()
:td()
:IF(entry.unlock_profession)
:IF(entry.unlock_profession)
Line 87: Line 87:
:done()
:done()
:done()
:done()

return tbl
return tbl
end
end
Line 99: Line 99:
:th('Combat level'):done()
:th('Combat level'):done()
:done()
:done()

for _, entry in ipairs(results) do
for _, entry in ipairs(results) do
out = p.insert_row(out, entry)
out = p.insert_row(out, entry)
end
end

return out
return out
end
end
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

This page is a member of a hidden category: