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

Материал из Space Station 14 Вики
Нет описания правки
Нет описания правки
Строка 20: Строка 20:
     for type, recipes in pairs(p.meals) do
     for type, recipes in pairs(p.meals) do
         for recipeId, recipe in pairs(recipes) do
         for recipeId, recipe in pairs(recipes) do
             if (recipeId == id) or (recipe["id"] == id) then
             if (recipeId:gsub(' ', '') == id:gsub(' ', '')) or (recipe["id"]:gsub(' ', '') == id:gsub(' ', '')) then
                 out = type
                 out = type
                 break
                 break

Версия от 10:02, 21 октября 2023

Для документации этого модуля может быть создана страница Модуль:Meals Lookup/doc

local prototypes = mw.loadData("Module:Meals Lookup/data")

local p = {}
p.meals = prototypes.meals


function p.getrecipesfromtype(frame) -- {{#invoke:Meals Lookup|getrecipesfromtype|ProtoID}}
    local out = ""

return out
end

function p.buildrecipebox(frame)
    local out = ""
return out
end

function p.getrecipetype(frame, id)
    local out = "nil"
    for type, recipes in pairs(p.meals) do
        for recipeId, recipe in pairs(recipes) do
            if (recipeId:gsub(' ', '') == id:gsub(' ', '')) or (recipe["id"]:gsub(' ', '') == id:gsub(' ', '')) then
                out = type
                break
            end
        end
        if out ~= "nil" then
            break
        end
    end
return out
end

function p.tests(frame)
    local out = ""
    out = p.getrecipetype(frame, frame.args[1])
return out
end


return p