Module:Sandbox/User:Alsang/NodeDescriptionChecker: Difference between revisions

add function to check if pages and recipes exist
(oh and the skill icon too, I suppose)
(add function to check if pages and recipes exist)
Line 29:
 
return p.displayTable(results)
--return p.generateLogTable()
--for debugging
Line 253 ⟶ 255:
 
return out
end
 
function p.generateLogTable()
-- looks to see which logs, planks, poles, staves, and posts have pages and recipes
 
local woodTypes = {'Ash','Oak','Pine','Hickory','Juniper','Poplar','Suave','Yew'}
local variantTypes = {'Coarse','Rugged','Average','Fine','Sturdy','Perfect'}
local itemTypes = {'Log','Post','Pole'}
local itemTypesAsh = {'Log','Plank'}
local itemTypesJuniper = {'Log','Stave'}
local out = mw.html.create('table')
:addClass('wikitable')
for i, variant in ipairs(variantTypes) do
local row = out:tag('tr')
for j, wood in ipairs(woodTypes) do
local cell = row:tag('td')
local itemTypesThis = itemTypes
if wood == 'Ash' then
itemTypesThis = itemTypesAsh
elseif wood == 'Juniper' then
itemTypesThis = itemTypesJuniper
end
 
for k, item in ipairs(itemTypesThis) do
local name = variant .. ' ' .. wood .. ' ' .. item
cell:wikitext('[[' .. name .. ']]')
if not(item=='Log') then
local query = mw.smw.ask('[[Name::' .. name .. ']][[Recipe JSON::~*]]|?#-')
local result = tostring(query)
cell:wikitext(', recipe:' .. result)
end
cell:wikitext('<br>')
end
end
end
return out
end
 
21,283

edits