Module:Sandbox/User:Alsang: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Blanked the page)
Tag: Blanking
(make table to check pages and recipes for stonemason)
Line 1: Line 1:
p = {}

function p.main()
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
local rocks ={'flint','basalt','andesite','granite','deathstone'}
local weapons = {'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 allWeapons = {}
for i,item in ipairs(variants) do
for j,jtem in ipairs(weapons) do
table.insert(allWeapons,{name=variants[i] .. ' ' .. weapons[j]})
table.insert(allWeapons,{name=weapons[j] .. ' (' .. variants[i] .. ')'})
end
end

for i,item in ipairs(allWeapons) do
local query = mw.smw.ask('[[Name::' .. item.name .. ']]|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].facility = query[1].data
end
local query = mw.smw.ask('[[Name::' .. item.name .. ']]|?Activity XP #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].XP = query[1].data
end
local query = mw.smw.ask('[[Name::' .. item.name .. ']]|?Activity duration #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].duration = query[1].data
end
local query = mw.smw.ask('[[Name::' .. item.name .. ']]|?Activity KP #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].KP = query[1].data
end
local query = mw.smw.ask('[[Name::' .. item.name .. ']]|?Recipe output #- = data|mainlabel=-')
if type(query)=='table' then
allWeapons[i].output = query[1].data
end
end
local out = mw.html.create('table')
out:addClass('wikitable sortable')
out:tag('th')
out:wikitext('Page')
out:done()
out:tag('th')
out:wikitext('Output')
out:done()
out:tag('th')
out:wikitext('Facility')
out:done()
out:tag('th')
out:wikitext('XP')
out:done()
out:tag('th')
out:wikitext('KP')
out:done()
out:tag('th')
out:wikitext('duration')
out:done()
for i,item in ipairs(allWeapons) do
out:tag('td')
out:wikitext('[[' .. item.name .. ']]')
out:done()
out:tag('td')
out:wikitext(allWeapons[i].output)
out:done()
out:tag('td')
out:wikitext(allWeapons[i].facility)
out:done()
out:tag('td')
out:wikitext(allWeapons[i].XP)
out:done()
out:tag('td')
out:wikitext(allWeapons[i].KP)
out:done()
out:tag('td')
out:wikitext(allWeapons[i].duration)
out:done()
end
return out
--for debugging
--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
end

return p