Module:Sandbox/User:Alsang: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
Tag: Manual revert
No edit summary
(51 intermediate revisions by the same user not shown)
Line 1: Line 1:
p = {}
p = {}

p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'


function p.main()
function p.main()
return nil
end

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


local results = mw.smw.ask(p.query)
function p.metal()
return p.makeTable('metal')
end

function p.bone()
return p.makeTable('bone')
end
function p.makeTable(args)
local out = mw.html.create('table')
local variants = {'basic','moderate','fine','strong','superior','perfect'}
:addClass('wikitable sortable')
local variants2 = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
for _,page in ipairs(results) do
local weaponsStone = {
out:tag('tr')
'Hammerfist',
:tag('th')
'Throwing Stones',
:wikitext('[[' .. page.name .. ']]')
'Stone Slab Shield',
:done()
'Stone Mace',
:tag('td')
'Stone Discs',
:wikitext('[[' .. page.name .. ' (basic)]]')
'War Hammer',
:done()
'Bolas',
:tag('td')
'Stone Chunk Shield',
:wikitext('[[' .. page.name .. ' (moderate)]]')
'Double Headed Hammer',
:done()
'Throwing Clubs',
:tag('td')
'Great Stone Mace',
:wikitext('[[' .. page.name .. ' (fine)]]')
' Polished Stone Shield',
:done()
'Throwing Hammers',
:tag('td')
'Great Hammer',
:wikitext('[[' .. page.name .. ' (strong)]]')
'Sling'}
:done()
local weaponsMetal = {
'Rapier ',
:tag('td')
:wikitext('[[' .. page.name .. ' (superior)]]')
'Throwing Twinblades',
:done()
'Metal Kite Shield',
:tag('td')
'Flanged Mace',
:wikitext('[[' .. page.name .. ' (perfect)]]')
'Throwing Rings',
:done()
'Shortsword',
:done()
'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
end
local allWeapons = {}
return out
for j,wep in ipairs(weapons) do
table.insert(allWeapons,{page='[[' .. wep .. ']]'})
end
end


function p.main2()
for i,var in ipairs(variants) do
for j,wep in ipairs(weapons) do
table.insert(allWeapons,{page='[[' .. wep .. ' (' .. var .. ')]]',wrong='[[' .. wep .. ' (' .. variants2[i] .. ')]]',redirect='[[' .. variants2[i] .. ' ' .. wep .. ']]'})
end
end
local results = mw.smw.ask(p.query)
for i,item in ipairs(allWeapons) do
local query = mw.smw.ask(item.page .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.item = query[1].data
end
local query = mw.smw.ask(item.page .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.facility = query[1].data
end
end
local out = mw.html.create('table')
local out = mw.html.create('table')
:addClass('wikitable sortable')
:addClass('wikitable sortable')
for _,page in ipairs(results) do
:tag('tr')
out:tag('tr')
:tag('th')
:tag('th')
:wikitext('Name of page')
:attr{ rowspan = '2' }
:wikitext('[[' .. page.name .. ']]')
:done()
:done()
:tag('th')
:tag('td')
:wikitext('Item on page')
:wikitext('[[File:' .. page.name .. ' (basic).png]]')
:done()
:done()
:tag('th')
:tag('td')
:wikitext('Recipe Facility')
:wikitext('[[File:' .. page.name .. ' (moderate).png]]')
:done()
:done()
:tag('th')
:tag('td')
:wikitext('Redirect page')
:wikitext('[[File:' .. page.name .. ' (fine).png]]')
:done()
:done()
:tag('th')
:tag('td')
:wikitext('Incorrect page name')
:wikitext('[[File:' .. page.name .. ' (strong).png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (superior).png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (perfect).png]]')
:done()
:done()
:done()
:done()
:tag('tr')
:tag('td')
for i,item in ipairs(allWeapons) do
:wikitext('[[File:' .. page.name .. ' (basic) dye.png]]')
local row = out:tag('tr')
:tag('td')
:wikitext(item.page)
:done()
:tag('td')
:wikitext(item.item)
:done()
:tag('td')
:wikitext(item.facility)
:done()
:tag('td')
:wikitext(item.redirect)
:done()
:tag('td')
:wikitext(item.wrong)
:done()
:done()
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (moderate) dye.png]]')
:done()
:done()
:tag('td')
end
:wikitext('[[File:' .. page.name .. ' (fine) dye.png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (strong) dye.png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (superior) dye.png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (perfect) dye.png]]')
:done()
:done()
end
return out
return out
end
end



return p
return p

Revision as of 20:30, 1 January 2025

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 = {}

p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'

function p.main()

	local results = mw.smw.ask(p.query)
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
	for _,page in ipairs(results) do
		out:tag('tr')
			:tag('th')
				:wikitext('[[' .. page.name .. ']]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (basic)]]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (moderate)]]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (fine)]]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (strong)]]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (superior)]]')
			:done()
			:tag('td')
				:wikitext('[[' .. page.name .. ' (perfect)]]')
			:done()
		:done()
	end
	
	return out
	
end

function p.main2()
	
	local results = mw.smw.ask(p.query)
	
	local out = mw.html.create('table')
		:addClass('wikitable sortable')
	for _,page in ipairs(results) do
		out:tag('tr')
			:tag('th')
				:attr{ rowspan = '2' }
				:wikitext('[[' .. page.name .. ']]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (basic).png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (moderate).png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (fine).png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (strong).png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (superior).png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (perfect).png]]')
			:done()
		:done()
		:tag('tr')
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (basic) dye.png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (moderate) dye.png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (fine) dye.png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (strong) dye.png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (superior) dye.png]]')
			:done()
			:tag('td')
				:wikitext('[[File:' .. page.name .. ' (perfect) dye.png]]')
			:done()
		:done()
	end
	
	return out
	
end


return p