Module:Sandbox/User:Alsang: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
(tidy up completed tables)
No edit summary
 
(53 intermediate revisions by the same user not shown)
Line 1: Line 1:
p = {}


local p = {}
function p.main(args)

function p.minerPages()
local queryString = '[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]'
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}

local weapons1 = {'Hammerfist','Throwing Stones','Stone Slab Shield',
return p.main(queryString)
'Stone Mace','Stone Discs','War Hammer',

'Bolas','Stone Chunk Shield','Double Headed Hammer',
end
'Throwing Clubs','Great Stone Mace',' Polished Stone Shield',

'Throwing Hammers','Great Hammer','Sling'}
function p.foragerPages()
local weapons2 = {'Hammerfist','Throwing Stones','Stone Slab Shield',
'Stone Mace','Stone Discs','War Hammer',
'Bolas','Stone Chunk Shield','Double Headed Hammer',
'Throwing Clubs','Great Stone Mace',' Polished Stone Shield',
'Throwing Hammers','Great Hammer','Sling'}
local weapons3 = {'Hammerfist','Throwing Stones','Stone Slab Shield',
'Stone Mace','Stone Discs','War Hammer',
'Bolas','Stone Chunk Shield','Double Headed Hammer',
'Throwing Clubs','Great Stone Mace',' Polished Stone Shield',
'Throwing Hammers','Great Hammer','Sling'}
local queryString = '[[Variant of::Kelp||Wallplant||Periwinkle||Shell||Potato||Pond Weed||Bellplant||Monument Piece||Water Lily||Starfish||Hogberries||Limpet||Nettle||Wrack]]'
weapons = weapons1

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]]'
local allWeapons = {}

for i,item in ipairs(variants) do
return p.main(queryString)
for j,jtem in ipairs(weapons) do

table.insert(allWeapons,{pagename='[[' .. jtem .. ' (' .. item .. ')]]',wrongname='[[' .. item .. ' ' .. jtem .. ']]'})
end
end
end


function p.gathererPages2()
for i,item in ipairs(allWeapons) do
local queryString = '[[Variant of::Tangfruit||Catkin||Femur Shard||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'

local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
return p.main(queryString)
if type(query)=='table' then

item.facility = query[1].data
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
else
page.node = page.name .. ' (skill node)'
end
end
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
page.JSON = (result and result[1] and result[1].data) or ''
local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
if type(query)=='table' then
if type(page.JSON)=='table' then
page.JSON = table.concat(page.JSON,'<br>')
item.XP = query[1].data
end
end
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-')
if type(query)=='table' then
item.duration = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-')
if type(query)=='table' then
item.KP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-')
if type(query)=='table' then
item.output = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.name = query[1].data
end
end
end
Line 68: Line 63:
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:wikitext('Page')
:wikitext('Variant')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Item name')
:wikitext('Level')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Recipe Output')
:wikitext('Page')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Facility')
:wikitext('Node')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('XP')
:wikitext('Node JSON')
:done()
:done()
:tag('th')
:done()

:wikitext('KP')
for i, item in ipairs(results) do
local row = out:tag('tr')
--level
:tag('td')
:wikitext(item.variant)
:done()
:done()
:tag('th')
:tag('td')
:wikitext('duration')
:wikitext(item.level)
:done()
:done()
:tag('th')
:tag('td')
:wikitext('Wrong Page (shouldnt exist)')
:wikitext('[['..item.name..']]')
:done()
:done()
:done()
:tag('td')
:wikitext('[['..item.node..']]')
for i,item in ipairs(allWeapons) do
local row = out:tag('tr')
:tag('td')
:wikitext(item.pagename)
:done()
:tag('td')
:wikitext(item.name)
:done()
:tag('td')
:wikitext(item.output)
:done()
:tag('td')
:wikitext(item.facility)
:done()
:tag('td')
:wikitext(item.XP)
:done()
:tag('td')
:wikitext(item.KP)
:done()
:tag('td')
:wikitext(item.duration)
:done()
:tag('td')
:wikitext(item.wrongname)
:done()
:done()
:done()
:tag('td')
:wikitext(item.JSON)
:done()
:done()
end
end
return out
--for debugging
--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
return out

end
end



Latest revision as of 00:24, 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
		else
			page.node = page.name .. ' (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('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.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