Module:Sandbox/User:Alsang: Difference between revisions

no edit summary
No edit summary
No edit summary
(68 intermediate revisions by the same user not shown)
Line 1:
local getArgs = require('Module:Arguments').getArgs
 
p = {}
 
p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'
function p.main(frame)
 
local args = getArgs(frame)
function p.main()
 
local results = mw.smw.ask(p.query)
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 = {}
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
return out
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')
:wikitext(attr{ rowspan = 'Page2') }
:wikitext('[[' .. page.name .. ']]')
:done()
:tag('thtd')
:wikitext('Item[[File:' .. page.name .. ' (basic).png]]')
:done()
:tag('thtd')
:wikitext('Facility[[File:' .. page.name .. ' (moderate).png]]')
:done()
:tag('thtd')
:wikitext('Wrong[[File:' Page.. (shouldntpage.name exist.. ' (fine).png]]')
:done()
:tag('thtd')
:wikitext('Wrongpage[[File:' Item.. page.name .. ' (strong).png]]')
:done()
:tag('thtd')
:wikitext('Wrongpage[[File:' Facility.. page.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
20,118

edits