Module:ChefPassiveList: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
m (display IMG ERR for missing image, but its the ~same size as an image) |
(simplify code: doesnt need to screen all chef recipes for which are passive, just specify a list of variants instead) |
||
Line 12: | Line 12: | ||
-- other parameters are determined by subqueries of chained pages |
-- other parameters are determined by subqueries of chained pages |
||
local query = { |
local query = { |
||
'[[Variant of::Roasted Sturlet||Dab Stew||Mackibut on Toast||Baked Bream||Garlic Herring]]', |
|||
'[[-Sold item.Sold by::Head Chef (shop)]]', |
|||
'?Profession Level A = lvl', |
'?Profession Level A = lvl', |
||
'? #- = name', |
'? #- = name', |
||
Line 23: | Line 23: | ||
} |
} |
||
local results = mw.smw.ask(query) |
local results = mw.smw.ask(query) |
||
results = p.screenResults(results,true) |
|||
results = p.formatResults(results) |
results = p.formatResults(results) |
||
Line 47: | Line 45: | ||
end |
end |
||
return currency._cell(amount, { html = 'yes' }) |
return currency._cell(amount, { html = 'yes' }) |
||
end |
|||
-- Need to split the table into two, lines with crates are passive and lines without are not |
|||
function p.screenResults(results,isPassive) |
|||
local resultsPassive = {} |
|||
local resultsNotPassive = {} |
|||
-- iterate through products |
|||
for _, item in ipairs(results) do |
|||
local hasCrate = string.find(item.recipeJSON,'Crate') |
|||
if hasCrate then |
|||
table.insert(resultsPassive,item) |
|||
else |
|||
table.insert(resultsNotPassive,item) |
|||
end |
|||
end |
|||
if isPassive then |
|||
return resultsPassive |
|||
else |
|||
return resultsNotPassive |
|||
end |
|||
end |
end |
||