Module:Sandbox/User:Alsang: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 1: Line 1:

local p = {}
local p = {}


local Infobox = require('Module:Infobox')
function p.gathererPages1()
local parse = require('Module:Param Parse')
local queryString = '[[Variant of::Globeplant||Dandelion||Apple||Haleberries||Chestnut||Catkin||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'
return p.main(queryString)
end


function p.gathererPages2()
function p.main(frame)
local args = frame:getParent().args
local queryString = '[[Variant of::Bone Spike||Femur Shard||Goat Horn||Rams Horn]]'
return p.main(queryString)
local config = {
end
infobox_name = 'Variant Category',

class = {Infobox.smw_param('episode'), Infobox.smw_param('variant_type')},
function p.gathererPages3()
local queryString = '[[Variant of::Leek||Bitterfruit||Tangfruit]]'
return p.main(queryString)
end

function p.main(queryString)

local query = {
queryString,
'? #- = name',
'?Profession Level A = level',
'?Variant of #-= variant',
'sort = Variant of,Profession Level A',
'limit = 500'
}
}
local results = mw.smw.ask(query)
local params = {
for _,page in ipairs(results) do
if string.find(page.name,'Mine') then
parse.name,
parse.image,
page.node = page.name
parse.release,
page.nodevar = page.variant
parse.premium,
else
parse.episode,
page.node = page.name .. ' (skill node)'
parse.additional_episode,
page.nodevar = page.variant .. ' (skill node)'
parse.variant_type,
end
}
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
page.JSON = (result and result[1] and result[1].data) or ''
if type(page.JSON)=='table' then
page.JSON = table.concat(page.JSON,'<br>')
end
end
local out = mw.html.create('table')
local infobox = Infobox.new(config, params, args)
infobox
:addClass('wikitable sortable')
:tag('tr')
:add_row{
{tag='th', content=Infobox.param('name'), class='infobox-header', colspan='20'},
:tag('th')
}
:wikitext('Variant')
:done()
:add_row{
{tag='td', content=Infobox.param('image'), class='infobox-image', colspan='20'},
:tag('th')
}
:wikitext('Node Variant')
:done()
:add_row{
:tag('th')
{tag='th', content='Release', colspan="6"},
{tag='td', content=Infobox.param('release'), colspan="14"},
:wikitext('Level')
}
:done()
local additional_episode = infobox:is_param_defined(Infobox.param('additional_episode')) > 0
:tag('th')
if additional_episode then
:wikitext('Page')
infobox:add_row{
:done()
{tag='th', content='[[Episodes]]', colspan="6", rowspan="2"},
:tag('th')
{tag='td', content=Infobox.param('episode'), colspan="14"},
:wikitext('Node')
}
:done()
:tag('th')
:add_row{
{tag='td', content=Infobox.param('additional_episode'), colspan="14"},
:wikitext('Node JSON')
}
:done()
local additional_episode_class = 'infobox-'..infobox:get_param(Infobox.smw_param('additional_episode'), 0)..'-additional'
:done()
additional_episode_class = mw.ustring.gsub(additional_episode_class, '%s', '_')

infobox:addClass(additional_episode_class)
for i, item in ipairs(results) do
else
local row = out:tag('tr')
infobox:add_row{
{tag='th', content='[[Episode]]', colspan="6"},
--level
{tag='td', content=Infobox.param('episode'), colspan="14"},
:tag('td')
}
:wikitext('[['..item.variant..']]')
:done()
:tag('td')
:wikitext('[['..item.nodevar..']]')
:done()
:tag('td')
:wikitext(item.level)
:done()
:tag('td')
:wikitext('[['..item.name..']]')
:done()
:tag('td')
:wikitext('[['..item.node..']]')
:done()
:tag('td')
:wikitext(item.JSON)
:done()
end
end
infobox
:add_row{
{tag='th', content='[[Premium Pass|Premium]]', colspan="6"},
{tag='td', content=Infobox.param('premium'), colspan="14"},
}
:add_row{
{tag='th', content='[[Variant]] type', colspan="6"},
{tag='td', content=Infobox.param('variant_type'), colspan="14"},
}
:pad('20')
return out
return infobox

end
end



Revision as of 20:29, 28 December 2024

Module documentation
This documentation is transcluded from Module:Sandbox/User:Alsang/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Sandbox/User:Alsang/doc. [edit]
Module:Sandbox/User:Alsang's function main is invoked by Template:Sandbox/User:Alsang.
Module:Sandbox/User:Alsang requires Module:Infobox.
Module:Sandbox/User:Alsang requires Module:Param Parse.

local p = {}

local Infobox = require('Module:Infobox')
local parse = require('Module:Param Parse')

function p.main(frame)
	local args = frame:getParent().args
	
	local config = {
		infobox_name = 'Variant Category',
		class = {Infobox.smw_param('episode'), Infobox.smw_param('variant_type')},
	}
	
	local params = {
		parse.name,
		parse.image,
		parse.release,
		parse.premium,
		parse.episode,
		parse.additional_episode,
		parse.variant_type,
	}
	
	local infobox = Infobox.new(config, params, args)
	infobox
		:add_row{
			{tag='th', content=Infobox.param('name'), class='infobox-header', colspan='20'},
		}
		:add_row{
			{tag='td', content=Infobox.param('image'), class='infobox-image', colspan='20'},
		}
		:add_row{
			{tag='th', content='Release', colspan="6"},
			{tag='td', content=Infobox.param('release'), colspan="14"},
		}
	local additional_episode = infobox:is_param_defined(Infobox.param('additional_episode')) > 0
	if additional_episode then
		infobox:add_row{
			{tag='th', content='[[Episodes]]', colspan="6", rowspan="2"},
			{tag='td', content=Infobox.param('episode'), colspan="14"},
		}
		:add_row{
			{tag='td', content=Infobox.param('additional_episode'), colspan="14"},
		}
		local additional_episode_class = 'infobox-'..infobox:get_param(Infobox.smw_param('additional_episode'), 0)..'-additional'
		additional_episode_class = mw.ustring.gsub(additional_episode_class, '%s', '_')
		infobox:addClass(additional_episode_class)
	else
		infobox:add_row{
			{tag='th', content='[[Episode]]', colspan="6"},
			{tag='td', content=Infobox.param('episode'), colspan="14"},
		}
	end
	infobox
		:add_row{
			{tag='th', content='[[Premium Pass|Premium]]', colspan="6"},
			{tag='td', content=Infobox.param('premium'), colspan="14"},
		}
		:add_row{
			{tag='th', content='[[Variant]] type', colspan="6"},
			{tag='td', content=Infobox.param('variant_type'), colspan="14"},
		}
		:pad('20')
	
	return infobox
end

return p