p = {}
p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'
function p.main()
return nil
end
local results = mw.smw.ask(p.query)
function p.stone()
return p.makeTable('stone')
end
function p.metal()
return p.makeTable('metal')
end
function p.bone()
return p.makeTable('bone')
end
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'}
local out = mw.html.create('table')
if args=='stone' then
:addClass('wikitable sortable')
weapons = weaponsStone
for _,page in ipairs(results) do
elseif args=='metal' then
out:tag('tr')
weapons = weaponsMetal
:tag('th')
elseif args=='bone' then
:wikitext('[[' .. page.name .. ']]')
weapons = weaponsBone
:done()
else
:tag('td')
return nil
: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
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 .. ']]',thirdThing='[[(' .. 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')
:attr{ rowspan = '2' }
:wikitext('Name of page (suffix)')
:wikitext('[[' .. page.name .. ']]')
:done()
:tag('thtd')
:wikitext('Item[[File:' on.. page.name .. ' (suffixbasic).png]]')
:done()
:tag('thtd')
:wikitext('Recipe[[File:' Facility.. page.name .. ' (suffixmoderate).png]]')
:done()
:tag('thtd')
:wikitext('Name[[File:' of.. page.name .. ' (prefixfine).png]]')
:done()
:tag('thtd')
:wikitext('Item[[File:' on.. page.name .. ' (prefixstrong).png]]')
:done()
:tag('thtd')
:wikitext('Recipe[[File:' Facility.. page.name .. ' (prefixsuperior).png]]')
:done()
:tag('thtd')
:wikitext('3rd[[File:' thing.. 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()
:tag('td')
:wikitext(item.thirdThing)
: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
|