Модуль:Meals Lookup: различия между версиями
Mhamster (обсуждение | вклад) мНет описания правки |
Mhamster (обсуждение | вклад) Нет описания правки |
||
| Строка 107: | Строка 107: | ||
-- returns recipes which id is matched by pattern | -- returns recipes which id is matched by pattern | ||
function getrecipesbyname(frame, tabl, str) -- should not be inviked | function getrecipesbyname(frame, tabl, str, ignore) -- should not be inviked | ||
local out = {} | local out = {} | ||
local ign = "" | |||
if ignore ~= nil then ign = ignore end | |||
for type, recipes in pairs(tabl) do | for type, recipes in pairs(tabl) do | ||
out[type] = {} | out[type] = {} | ||
for recipeId, recipe in pairs(recipes) do | for recipeId, recipe in pairs(recipes) do | ||
if string.match(recipeId, str) then | if string.match(recipeId, str) and not string.match(recipeId, ign) then | ||
table.insert(out[type], recipe) | table.insert(out[type], recipe) | ||
end | end | ||
| Строка 121: | Строка 123: | ||
-- same as above, but returns recipes that *does not* match given pattern | -- same as above, but returns recipes that *does not* match given pattern | ||
function getotherrecipes(frame, tabl, str) -- should not be invoked | function getotherrecipes(frame, tabl, str, ignore) -- should not be invoked | ||
local out = {} | local out = {} | ||
local ign = "" | |||
if ignore ~= nil then ign = ignore end | |||
for type, recipes in pairs(tabl) do | for type, recipes in pairs(tabl) do | ||
if not table.containsk(out, type) then | if not table.containsk(out, type) then | ||
| Строка 128: | Строка 132: | ||
end | end | ||
for recipeId, recipe in pairs(recipes) do | for recipeId, recipe in pairs(recipes) do | ||
if not string.match(recipeId, str) then | if not string.match(recipeId, str) and not string.match(recipeId, ign) then | ||
if not table.containsv(out[type], recipe) then | if not table.containsv(out[type], recipe) then | ||
table.insert(out[type], recipe) | table.insert(out[type], recipe) | ||
| Строка 449: | Строка 453: | ||
local out = "" | local out = "" | ||
local tablo = p.meals | local tablo = p.meals | ||
local ignore = frame.args["ignore"] | |||
for _, patt in pairs(frame.args) do | for _, patt in pairs(frame.args) do | ||
local ids = getrecipesbyname(frame, tablo, patt) | local ids = getrecipesbyname(frame, tablo, patt, ignore) | ||
out = out .. p.buildrecipeboxuniversal(frame, ids) | out = out .. p.buildrecipeboxuniversal(frame, ids) | ||
end | end | ||
| Строка 460: | Строка 465: | ||
local out = "" | local out = "" | ||
local tablo = p.meals | local tablo = p.meals | ||
local ignore = frame.args["ignore"] | |||
for _, patt in pairs(frame.args) do | for _, patt in pairs(frame.args) do | ||
local ids = getotherrecipes(frame, tablo, patt) | local ids = getotherrecipes(frame, tablo, patt, ignore) | ||
out = out .. p.buildrecipeboxuniversal(frame, ids) | out = out .. p.buildrecipeboxuniversal(frame, ids) | ||
end | end | ||
| Строка 489: | Строка 495: | ||
local out = "" | local out = "" | ||
local tablo = p.meals | local tablo = p.meals | ||
local ignore = frame.args["ignore"] | |||
for _, patt in pairs(frame.args) do | for _, patt in pairs(frame.args) do | ||
for type, recipes in pairs(getrecipesbyname(frame, tablo, patt)) do | for type, recipes in pairs(getrecipesbyname(frame, tablo, patt, ignore)) do | ||
out = out .. type .. "(" | out = out .. type .. "(" | ||
for k, r in pairs(recipes) do | for k, r in pairs(recipes) do | ||