Module:Sandbox/User:Alsang

From Brighter Shores Wiki
Revision as of 17:57, 5 December 2024 by Alsang (talk | contribs)
Jump to navigation Jump to search
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.

p = {}

function p.main(args)
	
	local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
	local weapons1 = {'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 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'}
	
	weapons = weapons1
	
	local allWeapons = {}	
	for i,item in ipairs(variants) do
		for j,jtem in ipairs(weapons) do
			table.insert(allWeapons,{pagename='[[' .. jtem .. ' (' .. item .. ')]]',wrongname='[[' .. item .. ' ' .. jtem .. ']]'})
		end
	end

		
	for i,item in ipairs(allWeapons) do
			
		local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
		if type(query)=='table' then
			item.facility = query[1].data
		end
		
		local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
		if type(query)=='table' then
			item.XP = query[1].data
		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
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Page')
			:done()
			:tag('th')
				:wikitext('Item name')
			:done()
			:tag('th')
				:wikitext('Recipe Output')
			:done()
			:tag('th')
				:wikitext('Facility')
			:done()
			:tag('th')
				:wikitext('XP')
			:done()
			:tag('th')
				:wikitext('KP')
			:done()
			:tag('th')
				:wikitext('duration')
			:done()
			:tag('th')
				:wikitext('Wrong Page (shouldnt exist)')
			:done()
		:done()
		
		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()
		end
		
	return out
	
	--for debugging
	--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
	
end

function p.stones()
	
	local variants = {'Coarse','Rugged','Average','Fine','Sturdy','Perfect'}
	local stones ={'Flint','Basalt','Andesite','Granite','Deathstone'}
	
	local allStones = {}	
	for i,item in ipairs(variants) do
		for j,jtem in ipairs(stones) do
			table.insert(allStones,{pagename='[[' .. item .. ' ' .. jtem .. ' (Etched)]]',resource='[[' .. item .. ' ' .. jtem .. ']]'})
		end
	end

		
	for i,item in ipairs(allStones) do
		
		local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
		if type(query)=='table' then
			item.facility = query[1].data
		end
		
		local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
		if type(query)=='table' then
			item.XP = query[1].data
		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
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Page name')
			:done()
			:tag('th')
				:wikitext('Item name')
			:done()
			:tag('th')
				:wikitext('Resource')
			:done()
			:tag('th')
				:wikitext('Recipe Output')
			:done()
			:tag('th')
				:wikitext('Facility')
			:done()
			:tag('th')
				:wikitext('XP')
			:done()
			:tag('th')
				:wikitext('KP')
			:done()
			:tag('th')
				:wikitext('duration')
			:done()
		:done()
		
		for i,item in ipairs(allStones) do
			local row = out:tag('tr')
				:tag('td')
					:wikitext(item.pagename)
				:done()
				:tag('td')
					:wikitext(item.name)
				:done()
				:tag('td')
					:wikitext(item.resource)
				: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()
				
			:done()
			:done()
		end
		
	return out
	
	--for debugging
	--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
	
end

function p.metals()
	
	local metals ={'Laterite Iron','Folrian Cabranese','Sylentnite Flantium','Maloic Adathril',
					'Limonite Iron','Aulsian Cabranese','Yehrite Flantium','Rigic Adathril',
					'Goethite Iron','Babian Cabranese','Holmitite Flantium','Portoic Adathril',
					'Hematite Iron','Morian Cabranese','Amirite Flantium','Caric Adathril',
					'Magnetite Iron','Shaprian Cabranese','Eysite Flantium','Masic Adathril',
					'Siderite Iron','Temberian Cabranese','Seethalite Flantium','Fortoic Adathril'}
					
	
	local allMetals = {}	
	for i,item in ipairs(metals) do
		table.insert(allMetals,{pagename='[[' .. item .. ' Ingot]]',resource='[[' .. item .. ' Ore]]'})
	end

		
	for i,item in ipairs(allMetals) do
		
		local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
		if type(query)=='table' then
			item.facility = query[1].data
		end
		
		local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
		if type(query)=='table' then
			item.XP = query[1].data
		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
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Page name')
			:done()
			:tag('th')
				:wikitext('Item name')
			:done()
			:tag('th')
				:wikitext('Resource')
			:done()
			:tag('th')
				:wikitext('Recipe Output')
			:done()
			:tag('th')
				:wikitext('Facility')
			:done()
			:tag('th')
				:wikitext('XP')
			:done()
			:tag('th')
				:wikitext('KP')
			:done()
			:tag('th')
				:wikitext('duration')
			:done()
		:done()
		
		for i,item in ipairs(allMetals) do
			local row = out:tag('tr')
				:tag('td')
					:wikitext(item.pagename)
				:done()
				:tag('td')
					:wikitext(item.name)
				:done()
				:tag('td')
					:wikitext(item.resource)
				: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()
				
			:done()
			:done()
		end
		
	return out
	
	--for debugging
	--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
	
end

function p.bones()
	
	local bones ={'Crooked Goat Horn',
'Yellowing Rams Horn',
'Streaky Bone Spike',
'Cracked Femur Shard',
'Gray Goat Horn',
'Mottled Rams Horn',
'Dappled Bone Spike',
'Dusty Femur Shard',
'Ridged Goat Horn',
'Sturdy Rams Horn',
'Bistre Bone Spike',
'Weathered Femur Shard',
'Smooth Goat Horn',
'Chunky Rams Horn',
'Pointed Bone Spike',
'Striated Femur Shard',
'Long Goat Horn',
'Pristine Rams Horn',
'Jagged Bone Spike',
'Sharp Femur Shard',
'Robust Goat Horn',
'Immaculate Rams Horn',
'Razor Bone Spike',
'Chunky Femur Shard'}
				
	local allBones = {}	
	for i,item in ipairs(bones) do
		table.insert(allBones,{pagename='[[' .. item .. ' (Brewed)]]',resource='[[' .. item .. ']]'})
	end

		
	for i,item in ipairs(allBones) do
		
		local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
		if type(query)=='table' then
			item.facility = query[1].data
		end
		
		local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
		if type(query)=='table' then
			item.XP = query[1].data
		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
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Page name')
			:done()
			:tag('th')
				:wikitext('Item name')
			:done()
			:tag('th')
				:wikitext('Resource')
			:done()
			:tag('th')
				:wikitext('Recipe Output')
			:done()
			:tag('th')
				:wikitext('Facility')
			:done()
			:tag('th')
				:wikitext('XP')
			:done()
			:tag('th')
				:wikitext('KP')
			:done()
			:tag('th')
				:wikitext('duration')
			:done()
		:done()
		
		for i,item in ipairs(allBones) do
			local row = out:tag('tr')
				:tag('td')
					:wikitext(item.pagename)
				:done()
				:tag('td')
					:wikitext(item.name)
				:done()
				:tag('td')
					:wikitext(item.resource)
				: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()
				
			:done()
			:done()
		end
		
	return out
	
	--for debugging
	--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
	
end

function p.metalgoods()
	
allJewels = {
{pagename = '[[Bangle Shinerium Jewelry]]', lvl = 20, tablematerial = '[[Softglow Shinerium]]'},
{pagename = '[[Locket Shinerium Jewelry]]', lvl = 26, tablematerial = '[[Softglow Shinerium]]'},
{pagename = '[[Circlet Shinerium Jewelry]]', lvl = 32, tablematerial = '[[Glitterstream Shinerium]]'},
{pagename = '[[Bangle Silver Jewelry]]', lvl = 39, tablematerial = '[[Winterspirit Silver]]'},
{pagename = '[[Locket Silver Jewelry]]', lvl = 43, tablematerial = '[[Winterspirit Silver]]'},
{pagename = '[[Earrings Shinerium Jewelry]]', lvl = 49, tablematerial = '[[Glitterstream Shinerium]]'},
{pagename = '[[Pendant Shinerium Jewelry]]', lvl = 56, tablematerial = '[[Firefly Shinerium]]'},
{pagename = '[[Necklace Shinerium Jewelry]]', lvl = 60, tablematerial = '[[Firefly Shinerium]]'},
{pagename = '[[Earrings Silver Jewelry]]', lvl = 67, tablematerial = '[[Brightspire Silver]]'},
{pagename = '[[Locket Gold Jewelry]]', lvl = 73, tablematerial = '[[Hearthlight Gold]]'},
{pagename = '[[Necklace Silver Jewelry]]', lvl = 77, tablematerial = '[[Brightspire Silver]]'},
{pagename = '[[Earrings Gold Jewelry]]', lvl = 84, tablematerial = '[[Hearthlight Gold]]'},
{pagename = '[[Circlet Silver Jewelry]]', lvl = 90, tablematerial = '[[Gallant Silver]]'},
{pagename = '[[Ring Shinerium Jewelry]]', lvl = 95, tablematerial = '[[Resplendent Shinerium]]'},
{pagename = '[[Choker Shinerium Jewelry]]', lvl = 101, tablematerial = '[[Resplendent Shinerium]]'},
{pagename = '[[Earrings Purpladium Jewelry]]', lvl = 107, tablematerial = '[[Violet Purpladium]]'},
{pagename = '[[Ring Silver Jewelry]]', lvl = 112, tablematerial = '[[Gallant Silver]]'},
{pagename = '[[Pendant Silver Jewelry]]', lvl = 118, tablematerial = '[[Fullmoon Silver]]'},
{pagename = '[[Bangle Gold Jewelry]]', lvl = 122, tablematerial = '[[Lionsmane Gold]]'},
{pagename = '[[Ring Gold Jewelry]]', lvl = 129, tablematerial = '[[Lionsmane Gold]]'},
{pagename = '[[Choker Silver Jewelry]]', lvl = 135, tablematerial = '[[Fullmoon Silver]]'},
{pagename = '[[Necklace Gold Jewelry]]', lvl = 140, tablematerial = '[[Hightower Gold]]'},
{pagename = '[[Ring Purpladium Jewelry]]', lvl = 146, tablematerial = '[[Violet Purpladium]]'},
{pagename = '[[Bracelet Shinerium Jewelry]]', lvl = 152, tablematerial = '[[Lastwish Shinerium]]'},
{pagename = '[[Signet Ring Shinerium Jewelry]]', lvl = 157, tablematerial = '[[Lastwish Shinerium]]'},
{pagename = '[[Choker Gold Jewelry]]', lvl = 163, tablematerial = '[[Hightower Gold]]'},
{pagename = '[[Locket Purpladium Jewelry]]', lvl = 169, tablematerial = '[[Mulberry Purpladium]]'},
{pagename = '[[Bracelet Silver Jewelry]]', lvl = 174, tablematerial = '[[Whitestar Silver]]'},
{pagename = '[[Signet Ring Silver Jewelry]]', lvl = 180, tablematerial = '[[Whitestar Silver]]'},
{pagename = '[[Choker Purpladium Jewelry]]', lvl = 187, tablematerial = '[[Mulberry Purpladium]]'},
{pagename = '[[Cuff Links Shinerium Jewelry]]', lvl = 191, tablematerial = '[[Constellation Shinerium]]'},
{pagename = '[[Bracelet Gold Jewelry]]', lvl = 197, tablematerial = '[[Morningsun Gold]]'},
{pagename = '[[Signet Ring Gold Jewelry]]', lvl = 206},
{pagename = '[[Brooch Shinerium Jewelry]]', lvl = 226},
{pagename = '[[Necklace Purpladium Jewelry]]', lvl = 247},
{pagename = '[[Circlet Gold Jewelry]]', lvl = 260},
{pagename = '[[Bangle Purpladium Jewelry]]', lvl = 280},
{pagename = '[[Pendant Gold Jewelry]]', lvl = 301},
{pagename = '[[Cuff Links Silver Jewelry]]', lvl = 314},
{pagename = '[[Brooch Silver Jewelry]]', lvl = 334},
{pagename = '[[Signet Ring Purpladium Jewelry]]', lvl = 355},
{pagename = '[[Bracelet Purpladium Jewelry]]', lvl = 368},
{pagename = '[[Circlet Purpladium Jewelry]]', lvl = 388},
{pagename = '[[Brooch Gold Jewelry]]', lvl = 409},
{pagename = '[[Cuff Links Gold Jewelry]]', lvl = 422},
{pagename = '[[Pendant Purpladium Jewelry]]', lvl = 442},
{pagename = '[[Brooch Purpladium Jewelry]]', lvl = 463},
{pagename = '[[Cuff Links Purpladium Jewelry]]', lvl = 476},

}

	for i,item in ipairs(allJewels) do
		
		local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
		if type(query)=='table' then
			item.facility = query[1].data
		end
		
		local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
		if type(query)=='table' then
			item.XP = query[1].data
		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 .. '|?Uses item #- = data|mainlabel=-')
		if type(query)=='table' then
			item.input = 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
		
		local query = mw.smw.ask(item.pagename .. '|?Profession Level A #- = data|mainlabel=-')
		if type(query)=='table' then
			item.recipelvl = query[1].data
		end
		
	end
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Page name')
			:done()
			:tag('th')
				:wikitext('table lvl')
			:done()
			:tag('th')
				:wikitext('Table resource')
			:done()
			:tag('th')
				:wikitext('Item name')
			:done()
			:tag('th')
				:wikitext('Recipe Output')
			:done()
			:tag('th')
				:wikitext('Recipe Resource')
			:done()
			:tag('th')
				:wikitext('Facility')
			:done()
			:tag('th')
				:wikitext('Item lvl')
			:done()
			:tag('th')
				:wikitext('XP')
			:done()
			:tag('th')
				:wikitext('KP')
			:done()
			:tag('th')
				:wikitext('duration')
			:done()
		:done()
		
		for i,item in ipairs(allJewels) do
			local row = out:tag('tr')
				:tag('td')
					:wikitext(item.pagename)
				:done()
				:tag('td')
					:wikitext(item.lvl)
				:done()
				:tag('td')
					:wikitext(item.tablematerial)
				:done()
				:tag('td')
					:wikitext(item.name)
				:done()
				:tag('td')
					:wikitext(item.output)
				:done()
				:tag('td')
					:wikitext(item.input[1])
				:done()
				:tag('td')
					:wikitext(item.facility)
				:done()
				:tag('td')
					:wikitext(item.recipelvl)
				:done()
				:tag('td')
					:wikitext(item.XP)
				:done()
				:tag('td')
					:wikitext(item.KP)
				:done()
				:tag('td')
					:wikitext(item.duration)
				:done()
				
			:done()
			:done()
		end
		
	return out
	
	--for debugging
	--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
	
end

return p