Module:Sandbox/User:Alsang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
(starting to work) |
||
Line 34: | Line 34: | ||
limit = 500 |
limit = 500 |
||
end |
end |
||
-- Query for data |
-- Query for data |
||
local smw_data = mw.smw.ask{ |
local smw_data = mw.smw.ask{ |
||
'[[Activity |
'[[Uses item::' .. item .. ']] OR [[Activity input::' .. item .. ']] OR [[Activity container::' .. item .. ']]', |
||
'? |
'?Recipe JSON', |
||
'?Activity JSON', |
'?Activity JSON', |
||
showValues and '?Value', |
showValues and '?Value', |
||
Line 52: | Line 52: | ||
local produced_items = {} |
local produced_items = {} |
||
for _, product in ipairs(smw_data) do |
for _, product in ipairs(smw_data) do |
||
local jsons = product['Activity JSON'] |
local jsons = product['Recipe JSON'] or product['Activity JSON'] |
||
if type(jsons) == 'string' then |
if type(jsons) == 'string' then |
||
jsons = { jsons } |
jsons = { jsons } |
||
Line 61: | Line 61: | ||
json.Value = product.Value |
json.Value = product.Value |
||
-- Filter out when this item isn't actually used (Will happen on pages with multiple recipes) |
-- Filter out when this item isn't actually used (Will happen on pages with multiple recipes) |
||
-- if Array.any(json.materials, function(mat) |
|||
-- return mat.name == item |
|||
-- end) then |
|||
table.insert(parsed, json) |
table.insert(parsed, json) |
||
-- end |
|||
end |
end |
||
table.sort(parsed, recipe_sort) |
table.sort(parsed, recipe_sort) |