Module:Sandbox/User:Alsang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'} |
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'} |
||
local rocks ={'flint','basalt','andesite','granite','deathstone'} |
|||
local weapons = {'Hammerfist','Throwing Stones','Stone Slab Shield', |
local weapons = {'Hammerfist','Throwing Stones','Stone Slab Shield', |
||
'Stone Mace','Stone Discs','War Hammer', |
'Stone Mace','Stone Discs','War Hammer', |
||
Line 14: | Line 13: | ||
for i,item in ipairs(variants) do |
for i,item in ipairs(variants) do |
||
for j,jtem in ipairs(weapons) do |
for j,jtem in ipairs(weapons) do |
||
table.insert(allWeapons,{pagename='[[' .. |
table.insert(allWeapons,{pagename='[[' .. jtem .. ' (' .. item .. ')]]'}) |
||
end |
end |
||
end |
end |
||
Line 23: | Line 22: | ||
local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Uses facility #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.facility = query[1].data |
|||
end |
end |
||
local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Activity XP #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.XP = query[1].data |
|||
end |
end |
||
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.duration = query[1].data |
|||
end |
end |
||
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.KP = query[1].data |
|||
end |
end |
||
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.output = query[1].data |
|||
end |
end |
||
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-') |
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-') |
||
if type(query)=='table' then |
if type(query)=='table' then |
||
item.name = query[1].data |
|||
end |
end |
||
Line 86: | Line 85: | ||
:tag('td') |
:tag('td') |
||
:wikitext(item.name) |
: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() |
|||
:done() |
|||
end |
|||
return out |
|||
--for debugging |
|||
--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>' |
|||
end |
|||
function p.stones() |
|||
local variants = {'Coarse','Rugged','Fine','Sturdy','Perfect'} |
|||
local stones ={'Flint','Basalt','Andesite','Granite','Deathstone'} |
|||
local allStones = {} |
|||
for i,item in ipairs(variants) do |
|||
for j,jtem in ipairs(stones) do |
|||
table.insert(allStones,{pagename='[[' .. item .. ' ' .. jtem .. ' (Etched)]]',resource='[[' .. item .. ' ' .. jtem .. ']]'}) |
|||
end |
|||
end |
|||
for i,item in ipairs(allStones) do |
|||
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.pagename .. '|?Activity XP #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.XP = query[1].data |
|||
end |
|||
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.duration = query[1].data |
|||
end |
|||
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.KP = query[1].data |
|||
end |
|||
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.output = query[1].data |
|||
end |
|||
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.name = query[1].data |
|||
end |
|||
end |
|||
local out = mw.html.create('table') |
|||
:addClass('wikitable sortable') |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Page') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Item') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Resource') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Recipe Output') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Facility') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('XP') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('KP') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('duration') |
|||
:done() |
|||
:done() |
|||
for i,item in ipairs(allStones) do |
|||
local row = out:tag('tr') |
|||
:tag('td') |
|||
:wikitext(item.pagename) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.name) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.resource) |
|||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
Revision as of 10:50, 5 December 2024
Module documentation
This documentation is transcluded from Module:Sandbox/User:Alsang/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Sandbox/User:Alsang/doc. [edit]
Module:Sandbox/User:Alsang's function main is invoked by Template:Sandbox/User:Alsang.
p = {}
function p.main(args)
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'}
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,{pagename='[[' .. jtem .. ' (' .. item .. ')]]'})
end
end
for i,item in ipairs(allWeapons) do
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.pagename .. '|?Activity XP #- = data|mainlabel=-')
if type(query)=='table' then
item.XP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-')
if type(query)=='table' then
item.duration = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-')
if type(query)=='table' then
item.KP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-')
if type(query)=='table' then
item.output = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.name = query[1].data
end
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
:tag('tr')
:tag('th')
:wikitext('Page')
:done()
:tag('th')
:wikitext('Item')
:done()
:tag('th')
:wikitext('Recipe Output')
:done()
:tag('th')
:wikitext('Facility')
:done()
:tag('th')
:wikitext('XP')
:done()
:tag('th')
:wikitext('KP')
:done()
:tag('th')
:wikitext('duration')
:done()
:done()
for i,item in ipairs(allWeapons) do
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()
:done()
end
return out
--for debugging
--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
end
function p.stones()
local variants = {'Coarse','Rugged','Fine','Sturdy','Perfect'}
local stones ={'Flint','Basalt','Andesite','Granite','Deathstone'}
local allStones = {}
for i,item in ipairs(variants) do
for j,jtem in ipairs(stones) do
table.insert(allStones,{pagename='[[' .. item .. ' ' .. jtem .. ' (Etched)]]',resource='[[' .. item .. ' ' .. jtem .. ']]'})
end
end
for i,item in ipairs(allStones) do
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.pagename .. '|?Activity XP #- = data|mainlabel=-')
if type(query)=='table' then
item.XP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity duration #- = data|mainlabel=-')
if type(query)=='table' then
item.duration = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Activity KP #- = data|mainlabel=-')
if type(query)=='table' then
item.KP = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Recipe output #- = data|mainlabel=-')
if type(query)=='table' then
item.output = query[1].data
end
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.name = query[1].data
end
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
:tag('tr')
:tag('th')
:wikitext('Page')
:done()
:tag('th')
:wikitext('Item')
:done()
:tag('th')
:wikitext('Resource')
:done()
:tag('th')
:wikitext('Recipe Output')
:done()
:tag('th')
:wikitext('Facility')
:done()
:tag('th')
:wikitext('XP')
:done()
:tag('th')
:wikitext('KP')
:done()
:tag('th')
:wikitext('duration')
:done()
:done()
for i,item in ipairs(allStones) do
local row = out:tag('tr')
:tag('td')
:wikitext(item.pagename)
:done()
:tag('td')
:wikitext(item.name)
:done()
:tag('td')
:wikitext(item.resource)
: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()
:done()
end
return out
--for debugging
--return '<pre>'..mw.text.jsonEncode(allWeapons, mw.text.JSON_PRETTY)..'</pre>'
end
return p