Module:Room features: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Created page with "local p = {} function p.main(frame) local args = frame:getParent().args return p._main(args) end local categories = { 'Non-player characters', 'Monsters', 'Skill nodes', 'Scenery' } function base_query(location, category) return { '[[Has subobject::<q>Located in::' .. location .. '</q>]]', 'category=' .. category, '?#-', '?Name', '?Image#-', } end function p._main(args) local ret = '' local location = args[1] or mw.title.getCurrentTitle() f...") |
No edit summary |
||
Line 29: | Line 29: | ||
for _,cat in ipairs(categories) do |
for _,cat in ipairs(categories) do |
||
ret = ret .. '===' .. cat .. '===\n' |
ret = ret .. '===' .. cat .. '===\n' |
||
local query = mw.smw.ask(base_query(location, |
local query = mw.smw.ask(base_query(location, cat)) |
||
local gallery = '<gallery>\n' |
local gallery = '<gallery>\n' |
Revision as of 14:50, 3 November 2024
Module documentation
This documentation is transcluded from Module:Room features/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Room features/doc. [edit]
Module:Room features's function main is invoked by Template:Room features.
local p = {}
function p.main(frame)
local args = frame:getParent().args
return p._main(args)
end
local categories = {
'Non-player characters',
'Monsters',
'Skill nodes',
'Scenery'
}
function base_query(location, category)
return {
'[[Has subobject::<q>[[Located in::' .. location .. ']]</q>]]',
'category=' .. category,
'?#-',
'?Name',
'?Image#-',
}
end
function p._main(args)
local ret = ''
local location = args[1] or mw.title.getCurrentTitle()
for _,cat in ipairs(categories) do
ret = ret .. '===' .. cat .. '===\n'
local query = mw.smw.ask(base_query(location, cat))
local gallery = '<gallery>\n'
for i,v in ipairs(query or {}) do
gallery = gallery .. (v.Image or 'File:Section anchor light.svg') .. '|' .. '[[' .. v[1] .. '|' .. v.Name .. ']]\n'
end
gallery = gallery .. '</gallery>\n'
ret = ret .. frame:preprocess(gallery)
end
end
return p