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
 
(43 intermediate revisions by the same user not shown)
Line 1: Line 1:
p = {}


local p = {}
function p.main()

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

return p.main(queryString)


function p.stone()
return p.makeTable('stone')
end
end


function p.metal()
function p.foragerPages()
return p.makeTable('metal')
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
end


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

return p.main(queryString)

end
end

function p.gathererPages2()
local queryString = '[[Variant of::Tangfruit||Catkin||Femur Shard||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'
function p.makeTable(args)
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
local weaponsStone = {
'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 weaponsMetal = {
'Rapier ',
'Throwing Twinblades',
'Metal Kite Shield',
'Flanged Mace',
'Throwing Rings',
'Shortsword',
'Metal Javelins',
'Metal Heater Shield',
'Longsword',
'Throwing Knives',
'Broadsword',
'Metal Buckler',
'Throwing Axes',
'Battleaxe',
'Metal Bow'}
local weaponsBone = {
'Truncheon',
'Blowpipe',
'Wooden Round Shield',
'Cudgel',
'Javelins',
'Club',
'Light Crossbow',
'Wooden Square Shield',
'Quarterstaff',
'Recurve Bow',
'Spear',
'Wooden Hexagon Shield',
'Longbow',
'Poleaxe',
'Heavy Crossbow'}
if args=='stone' then
weapons = weaponsStone
elseif args=='metal' then
weapons = weaponsMetal
elseif args=='bone' then
weapons = weaponsBone
else
return nil
end
local allWeapons = {}
for j,jtem in ipairs(weapons) do
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ']]',prefixPage=''})
end


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

for j,jtem in ipairs(weapons) do
end
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ' (' .. item .. ')]]',prefixPage='[[' .. item .. ' ' .. jtem .. ']]'})

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
end
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
end
page.JSON = (result and result[1] and result[1].data) or ''
for i,item in ipairs(allWeapons) do
if type(page.JSON)=='table' then
page.JSON = table.concat(page.JSON,'<br>')
local query = mw.smw.ask(item.suffixPage .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.suffixItem = query[1].data
end
end
local query = mw.smw.ask(item.suffixPage .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.suffixFacility = query[1].data
end
local query = mw.smw.ask(item.prefixPage .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.prefixItem = query[1].data
end
local query = mw.smw.ask(item.prefixPage .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.prefixFacility = query[1].data
end
end
end
Line 118: Line 65:
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:wikitext('Suffix suffixPage')
:wikitext('Variant')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Suffix suffixItem')
:wikitext('Node Variant')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Suffix Recipe Facility')
:wikitext('Level')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Prefix suffixPage')
:wikitext('Page')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Prefix suffixItem')
:wikitext('Node')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Prefix Recipe Facility')
:wikitext('Node JSON')
:done()
:done()
:done()
:done()

for i, item in ipairs(results) do
local row = out:tag('tr')
--level
for i,item in ipairs(allWeapons) do
local row = out:tag('tr')
:tag('td')
:tag('td')
:wikitext('[['..item.variant..']]')
:wikitext(item.suffixPage)
:done()
:tag('td')
:wikitext(item.suffixItem)
:done()
:tag('td')
:wikitext(item.suffixFacility)
:done()
:tag('td')
:wikitext(item.prefixPage)
:done()
:tag('td')
:wikitext(item.prefixItem)
:done()
:tag('td')
:wikitext(item.prefixFacility)
:done()
:done()
:done()
:tag('td')
:wikitext('[['..item.nodevar..']]')
:done()
:done()
:tag('td')
end
:wikitext(item.level)
:done()
return out
:tag('td')
:wikitext('[['..item.name..']]')
--for debugging
:done()
--return '<pre>'..mw.text.jsonEncode(args, mw.text.JSON_PRETTY)..'</pre>'
:tag('td')
:wikitext('[['..item.node..']]')
:done()
:tag('td')
:wikitext(item.JSON)
:done()
end
return out

end
end



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