Модуль:Meals Lookup: различия между версиями

Нет описания правки
Отмена правки 44636, сделанной Mhamster (обсуждение)
Метка: отмена
Строка 107: Строка 107:


-- returns recipes which id is matched by pattern
-- returns recipes which id is matched by pattern
function getrecipesbyname(frame, tabl, str, ignore) -- should not be inviked
function getrecipesbyname(frame, tabl, str) -- 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) and not string.match(recipeId, ign) then
             if string.match(recipeId, str) then
                 table.insert(out[type], recipe)
                 table.insert(out[type], recipe)
             end
             end
Строка 123: Строка 121:


-- 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, ignore) -- should not be invoked
function getotherrecipes(frame, tabl, str) -- 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
Строка 132: Строка 128:
         end
         end
         for recipeId, recipe in pairs(recipes) do
         for recipeId, recipe in pairs(recipes) do
             if not string.match(recipeId, str) and not string.match(recipeId, ign) then
             if not string.match(recipeId, str) 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)
Строка 453: Строка 449:
     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, ignore)
         local ids = getrecipesbyname(frame, tablo, patt)
         out = out .. p.buildrecipeboxuniversal(frame, ids)
         out = out .. p.buildrecipeboxuniversal(frame, ids)
     end
     end
Строка 465: Строка 460:
     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, ignore)
         local ids = getotherrecipes(frame, tablo, patt)
         out = out .. p.buildrecipeboxuniversal(frame, ids)
         out = out .. p.buildrecipeboxuniversal(frame, ids)
     end
     end
Строка 495: Строка 489:
     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, ignore)) do
         for type, recipes in pairs(getrecipesbyname(frame, tablo, patt)) do
             out = out .. type .. "("
             out = out .. type .. "("
             for k, r in pairs(recipes) do
             for k, r in pairs(recipes) do