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
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:


function p.minerPages()
function p.minerPages()
local queryString = '[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]'

return p.main(queryString)

end

function p.foragerPages()
local queryString = '[[Variant of::Kelp||Wallplant||Periwinkle||Shell||Potato||Pond Weed||Bellplant||Monument Piece||Water Lily||Starfish||Hogberries||Limpet||Nettle||Wrack]]'

return p.main(queryString)

end

function p.gathererPages1()
local queryString = '[[Variant of::Globeplant||Dandelion||Goat Horn||Apple||Leek||Haleberries||Rams Horn||Bitterfruit||Chestnut||Bone Spike]]'

return p.main(queryString)

end

function p.gathererPages2()
local queryString = '[[Variant of::Tangfruit||Catkin||Femur Shard||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'

return p.main(queryString)

end

function p.main(queryString)


local query = {
local query = {
queryString,
'[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]',
'? #- = name',
'? #- = name',
'?Profession Level A = level',
'?Profession Level A = level',
'?Variant of = variant',
'?Variant of #-= variant',
'sort = Variant of,Profession Level A',
'sort = Variant of,Profession Level A',
'limit = 500'
'limit = 500'
Line 15: Line 47:
for _,page in ipairs(results) do
for _,page in ipairs(results) do
if string.find(page.name,'Mine') then
local result = mw.smw.ask('[['..page.name..' (skill node)]]|?Activity JSON = data')
page.node = page.name
if page.variant=='Mine Cart Work' then
page.nodevar = page.variant
result = mw.smw.ask('[['..page.name..']]|?Activity JSON = data')
end
else
page.JSON = (result and result[1] and result[1].data) or ''
page.node = page.name .. ' (skill node)'
page.nodevar = page.variant .. ' (skill node)'
if type(page.JSON)=='table' then
end
page.JSON = table.concat(page.JSON,'<br>')
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
end
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
end
Line 30: Line 66:
:tag('th')
:tag('th')
:wikitext('Variant')
:wikitext('Variant')
:done()
:tag('th')
:wikitext('Node Variant')
:done()
:done()
:tag('th')
:tag('th')
Line 50: Line 89:
--level
--level
:tag('td')
:tag('td')
:wikitext(item.variant)
:wikitext('[['..item.variant..']]')
:done()
:tag('td')
:wikitext('[['..item.nodevar..']]')
:done()
:done()
:tag('td')
:tag('td')
Line 59: Line 101:
:done()
:done()
:tag('td')
:tag('td')
:wikitext('[['..item.name..' (skill node)]]')
:wikitext('[['..item.node..']]')
:done()
:done()
:tag('td')
:tag('td')

Latest revision as of 20:10, 21 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.

local p = {}

function p.minerPages()
	
	local queryString = '[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]'

	return p.main(queryString)

end

function p.foragerPages()
	
	local queryString = '[[Variant of::Kelp||Wallplant||Periwinkle||Shell||Potato||Pond Weed||Bellplant||Monument Piece||Water Lily||Starfish||Hogberries||Limpet||Nettle||Wrack]]'

	return p.main(queryString)

end

function p.gathererPages1()
	
	local queryString = '[[Variant of::Globeplant||Dandelion||Goat Horn||Apple||Leek||Haleberries||Rams Horn||Bitterfruit||Chestnut||Bone Spike]]'

	return p.main(queryString)

end

function p.gathererPages2()
	
	local queryString = '[[Variant of::Tangfruit||Catkin||Femur Shard||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'

	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)
	
	for _,page in ipairs(results) do
		if string.find(page.name,'Mine') then
			page.node = page.name
			page.nodevar = page.variant
		else
			page.node = page.name .. ' (skill node)'
			page.nodevar = page.variant .. ' (skill node)'
		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')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Variant')
			:done()
			:tag('th')
				:wikitext('Node Variant')
			:done()
			:tag('th')
				:wikitext('Level')
			:done()
			:tag('th')
				:wikitext('Page')
			:done()
			:tag('th')
				:wikitext('Node')
			:done()
			:tag('th')
				:wikitext('Node JSON')
			:done()
		:done()

	for i, item in ipairs(results) do
		local row = out:tag('tr')
		
			--level
			: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
	
	return out

end

return p