Editing Module:Sandbox/User:Alsang

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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.gathererPages1()
local queryString = '[[Variant of::Globeplant||Dandelion||Apple||Haleberries||Chestnut||Catkin||Clover||Snake Scale||Orchid||Dock Leaf||Sage||Thistle]]'
return p.main(queryString)
end
end


function p.gathererPages2()
function p.stone()
return p.makeTable('stone')
local queryString = '[[Variant of::Bone Spike||Femur Shard||Goat Horn||Rams Horn]]'
return p.main(queryString)
end
end


function p.gathererPages3()
function p.metal()
return p.makeTable('metal')
local queryString = '[[Variant of::Leek||Bitterfruit||Tangfruit]]'
return p.main(queryString)
end
end


function p.main(queryString)
function p.bone()
return p.makeTable('bone')

end
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 j,jtem in ipairs(weapons) do
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ']]',prefixPage=''})
end

for i,item in ipairs(variants) do
for j,jtem in ipairs(weapons) do
table.insert(allWeapons,{suffixPage='[[' .. jtem .. ' (' .. item .. ')]]',prefixPage='[[' .. item .. ' ' .. jtem .. ']]'})
end
end
end
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
for i,item in ipairs(allWeapons) do
page.JSON = (result and result[1] and result[1].data) or ''
if type(page.JSON)=='table' then
local query = mw.smw.ask(item.suffixPage .. '|?Name #- = data|mainlabel=-')
page.JSON = table.concat(page.JSON,'<br>')
if type(query)=='table' then
item.suffixItem = query[1].data
end
end
local query = mw.smw.ask(item.suffixPage .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.suffixFacility = query[1].data
end
local query = mw.smw.ask(item.prefixPage .. '|?Name #- = data|mainlabel=-')
if type(query)=='table' then
item.prefixItem = query[1].data
end
local query = mw.smw.ask(item.prefixPage .. '|?Uses facility #- = data|mainlabel=-')
if type(query)=='table' then
item.prefixFacility = query[1].data
end
end
end
Line 48: Line 118:
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:wikitext('Variant')
:wikitext('Name of page (suffix)')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Node Variant')
:wikitext('Item on page (suffix)')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Level')
:wikitext('Recipe Facility (suffix)')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Page')
:wikitext('Name of page (prefix)')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Node')
:wikitext('Item on page (prefix)')
:done()
:done()
:tag('th')
:tag('th')
:wikitext('Node JSON')
:wikitext('Recipe Facility (prefix)')
: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('td')
local row = out:tag('tr')
:wikitext('[['..item.variant..']]')
:tag('td')
:wikitext(item.suffixPage)
:done()
:tag('td')
:wikitext(item.suffixItem)
:done()
:tag('td')
:wikitext(item.suffixFacility)
:done()
:tag('td')
:wikitext(item.prefixPage)
:done()
:tag('td')
:wikitext(item.prefixItem)
:done()
:tag('td')
:wikitext(item.prefixFacility)
:done()
:done()
:done()
:tag('td')
:wikitext('[['..item.nodevar..']]')
:done()
:done()
end
:tag('td')
:wikitext(item.level)
:done()
:tag('td')
:wikitext('[['..item.name..']]')
:done()
:tag('td')
:wikitext('[['..item.node..']]')
:done()
:tag('td')
:wikitext(item.JSON)
:done()
end
return out
return out

--for debugging
--return '<pre>'..mw.text.jsonEncode(args, mw.text.JSON_PRETTY)..'</pre>'
end
end


Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

This page is a member of a hidden category: