Module:Sandbox/User:Alsang: Difference between revisions

no edit summary
No edit summary
No edit summary
(80 intermediate revisions by the same user not shown)
Line 1:
p = {}
 
p.query = '[[Category:Guardian Equipment]] AND [[Variant type::~*]] AND [[Category:Armorer]]|?#-=name|limit=500'
function p.main(args)
 
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 rocks ={'flint','basalt','andesite','granite','deathstone'}
for _,page in ipairs(results) do
local weapons = {'Hammerfist','Throwing Stones','Stone Slab Shield',
out:tag('tr')
'Stone Mace','Stone Discs','War Hammer',
:tag('th')
'Bolas','Stone Chunk Shield','Double Headed Hammer',
:wikitext('[[' .. page.name .. ']]')
'Throwing Clubs','Great Stone Mace',' Polished Stone Shield',
:done()
'Throwing Hammers','Great Hammer','Sling'}
:tag('td')
:wikitext('[[' .. page.name .. ' (basic)]]')
local allWeapons = {}
:done()
for i,item in ipairs(variants) do
:tag('td')
for j,jtem in ipairs(weapons) do
table.insert :wikitext(allWeapons,{pagename='[[' .. weapons[j]page.name .. ' (' .. variants[i] .. 'moderate)]]'})
:done()
end
: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()
for i,item in ipairs(allWeapons) do
local results = mw.smw.ask(p.query)
local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].facility = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].XP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].duration = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].KP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].output = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].name = 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('Recipe[[File:' Output.. page.name .. ' (moderate).png]]')
:done()
:tag('thtd')
:wikitext('Facility[[File:' .. page.name .. ' (fine).png]]')
:done()
:tag('thtd')
:wikitext('XP[[File:' .. page.name .. ' (strong).png]]')
:done()
:tag('thtd')
:wikitext('KP[[File:' .. page.name .. ' (superior).png]]')
:done()
:tag('thtd')
:wikitext('duration[[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.name)
:done()
:tag('td')
:wikitext(item.output)
:done()
:tag('td')
:wikitext(item.facility)
:done()
:tag('td')
:wikitext(item.XP)
:done()
:tag('td')
:wikitext(item.KP)
:done()
:tag('td')
:wikitext(item.duration)
: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(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
end
 
 
return p
20,126

edits