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
function p.makeTable(args)
local out = mw.html.create('table')
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
:addClass('wikitable sortable')
local weaponsStone = {
for _,page in ipairs(results) do
'Hammerfist',
out:tag('tr')
'Throwing Stones',
:tag('th')
'Stone Slab Shield',
:wikitext('[[' .. page.name .. ']]')
'Stone Mace',
:done()
'Stone Discs',
:tag('td')
'War Hammer',
:wikitext('[[' .. page.name .. ' (basic)]]')
'Bolas',
:done()
'Stone Chunk Shield',
:tag('td')
'Double Headed Hammer',
:wikitext('[[' .. page.name .. ' (moderate)]]')
'Throwing Clubs',
:done()
'Great Stone Mace',
:tag('td')
' Polished Stone Shield',
:wikitext('[[' .. page.name .. ' (fine)]]')
'Throwing Hammers',
:done()
'Great Hammer',
:tag('Slingtd'})
:wikitext('[[' .. page.name .. ' (strong)]]')
local weaponsMetal = {
:done()
'Rapier ',
:tag('td')
'Throwing Twinblades',
:wikitext('[[' .. page.name .. ' (superior)]]')
'Metal Kite Shield',
:done()
'Flanged Mace',
:tag('td')
'Throwing Rings',
:wikitext('[[' .. page.name .. ' (perfect)]]')
'Shortsword',
:done()
'Metal Javelins',
:done()
'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 = {}
return out
for j,jtem in ipairs(weapons) do
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ']]',prefixPage=''})
end
function p.main2()
for i,item in ipairs(variants) do
for j,jtem in ipairs(weapons) do
local results = mw.smw.ask(p.query)
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ' (' .. item .. ')]]',prefixPage='[[' .. item .. ' ' .. jtem .. ']]'})
end
end
for i,item in ipairs(allWeapons) do
local query = mw.smw.ask(item.suffixPage .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.suffixItem = query[1].data
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
local out = mw.html.create('table')
:addClass('wikitable sortable')
for _,page in ipairs(results) do
:tag('tr')
out:tag('tr')
:tag('th')
:wikitext('Suffixattr{ rowspan = Page')2' }
:wikitext('[[' .. page.name .. ']]')
:done()
:tag('thtd')
:wikitext('Suffix[[File:' Item.. page.name .. ' (basic).png]]')
:done()
:tag('thtd')
:wikitext('Suffix[[File:' Recipe.. Facilitypage.name .. ' (moderate).png]]')
:done()
:tag('thtd')
:wikitext('Prefix[[File:' Page.. page.name .. ' (fine).png]]')
:done()
:tag('thtd')
:wikitext('Prefix[[File:' Item.. 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.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()
: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
|