Editing Module:Sandbox/User:Alsang
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
p = {} |
|||
function p.main() |
|||
local p = {} |
|||
return nil |
|||
function p.minerPages() |
|||
local queryString = '[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]' |
|||
return p.main(queryString) |
|||
end |
end |
||
function p. |
function p.stone() |
||
return p.makeTable('stone') |
|||
local queryString = '[[Variant of::Kelp||Wallplant||Periwinkle||Shell||Potato||Pond Weed||Bellplant||Monument Piece||Water Lily||Starfish||Hogberries||Limpet||Nettle||Wrack]]' |
|||
return p.main(queryString) |
|||
end |
end |
||
function p. |
function p.metal() |
||
return p.makeTable('metal') |
|||
local queryString = '[[Variant of::Globeplant||Dandelion||Goat Horn||Apple||Leek||Haleberries||Rams Horn||Bitterfruit||Chestnut||Bone Spike]]' |
|||
return p.main(queryString) |
|||
end |
end |
||
function p. |
function p.bone() |
||
return p.makeTable('bone') |
|||
local queryString = '[[Variant of::Tangfruit||Catkin||Femur Shard||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]' |
|||
return p.main(queryString) |
|||
end |
end |
||
function p.main(queryString) |
|||
local query = { |
|||
queryString, |
|||
'? #- = name', |
|||
'?Profession Level A = level', |
|||
'?Variant of #-= variant', |
|||
'sort = Variant of,Profession Level A', |
|||
'limit = 500' |
|||
} |
|||
local results = mw.smw.ask(query) |
|||
function p.makeTable(args) |
|||
for _,page in ipairs(results) do |
|||
if string.find(page.name,'Mine') then |
|||
local variants = {'Basic','Moderate','Fine','Strong','Superior','Perfect'} |
|||
page.node = page.name |
|||
local weaponsStone = { |
|||
page.nodevar = page.variant |
|||
'Hammerfist', |
|||
else |
|||
'Throwing Stones', |
|||
page.node = page.name .. ' (skill node)' |
|||
'Stone Slab Shield', |
|||
page.nodevar = page.variant .. ' (skill node)' |
|||
'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'} |
|||
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 |
||
end |
|||
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data') |
|||
page.JSON = (result and result[1] and result[1].data) or '' |
|||
for i,item in ipairs(allWeapons) do |
|||
if type(page.JSON)=='table' then |
|||
page.JSON = table.concat(page.JSON,'<br>') |
|||
local query = mw.smw.ask(item.pagename .. '|?Name #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.itemname = query[1].data |
|||
end |
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 |
end |
||
Line 65: | Line 114: | ||
:tag('tr') |
:tag('tr') |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Page') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Item name') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Facility') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext('Page') |
:wikitext('Wrong Page (shouldnt exist)') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Wrongpage Item name') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Wrongpage Facility') |
||
:done() |
:done() |
||
:done() |
:done() |
||
for i, item in ipairs(results) do |
|||
local row = out:tag('tr') |
|||
for i,item in ipairs(allWeapons) do |
|||
--level |
|||
:tag(' |
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() |
:done() |
||
:tag('td') |
|||
:wikitext('[['..item.nodevar..']]') |
|||
:done() |
:done() |
||
end |
|||
:tag('td') |
|||
:wikitext(item.level) |
|||
return out |
|||
:done() |
|||
:tag('td') |
|||
--for debugging |
|||
:wikitext('[['..item.name..']]') |
|||
--return '<pre>'..mw.text.jsonEncode(args, mw.text.JSON_PRETTY)..'</pre>' |
|||
:done() |
|||
:tag('td') |
|||
:wikitext('[['..item.node..']]') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.JSON) |
|||
:done() |
|||
end |
|||
return out |
|||
end |
end |
||