p = {}
p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'
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
local out = mw.html.create('table')
function p.makeTable(args)
: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
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'}
end
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 i,item in ipairs(variants) do
for j,jtem in ipairs(weapons) do
table.insert(allWeapons,{pagename='[[' .. jtem .. ' (' .. item .. ')]]',wrongname='[[' .. item .. ' ' .. jtem .. ']]'})
end
end
function p.main2()
for i,item in ipairs(allWeapons) do
local queryresults = mw.smw.ask(itemp.pagename .. '|?Name #- = data|mainlabel=-'query)
if type(query)=='table' then
item.itemname = query[1].data
end
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.wrongname .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.wrongitemname = query[1].data
end
local query = mw.smw.ask(item.wrongname .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.wrongfacility = query[1].data
end
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
for _,page in ipairs(results) do
:tag('tr')
out:tag('tr')
:tag('th')
:attr{ rowspan = '2' }
:wikitext('Suffix Pagename')
:wikitext('[[' .. page.name .. ']]')
:done()
:tag('thtd')
:wikitext('Suffix[[File:' Itemname.. page.name .. ' (basic).png]]')
:done()
:tag('thtd')
:wikitext('Suffix[[File:' Recipe.. Facilitypage.name .. ' (moderate).png]]')
:done()
:tag('thtd')
:wikitext('Prefix[[File:' Pagename.. page.name .. ' (fine).png]]')
:done()
:tag('thtd')
:wikitext('Prefix[[File:' Itemname.. page.name .. ' (strong).png]]')
:done()
:tag('thtd')
:wikitext('Prefix[[File:' Recipe.. Facilitypage.name .. ' (superior).png]]')
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (perfect).png]]')
: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.pagename)
:done()
:tag('td')
:wikitext(item.itemname)
:done()
:tag('td')
:wikitext(item.facility)
:done()
:tag('td')
:wikitext(item.wrongname)
:done()
:tag('td')
:wikitext(item.wrongitemname)
:done()
:tag('td')
:wikitext(item.wrongfacility)
:done()
:done()
:tag('td')
:wikitext('[[File:' .. page.name .. ' (moderate) dye.png]]')
: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
--for debugging
--return '<pre>'..mw.text.jsonEncode(args, mw.text.JSON_PRETTY)..'</pre>'
end
return p
|