Модуль:Prototypes/Машина/Станок: различия между версиями

мНет описания правки
Нет описания правки
Строка 159: Строка 159:
     end
     end


-- Обработка emagStaticRecipes
    -- Обработка emagStaticRecipes
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagStaticRecipes then
    if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagStaticRecipes then
    for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagStaticRecipes) do
        for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagStaticRecipes) do
        local recipe = getRecipeDetails(recipeId)
            local recipe = getRecipeDetails(recipeId)
        if recipe then
            if recipe then
            table.insert(recipes, {
                table.insert(recipes, {
                result = recipe.result,
                    result = recipe.result,
                completetime = recipe.completetime,
                    completetime = recipe.completetime,
                materials = recipe.materials,
                    materials = recipe.materials,
                discipline = "Static",
                    discipline = "Static",
                tier = 0,
                    tier = 0,
                isEmag = true
                    isEmag = true
            })
                })
        end
            end
    end
        end
end
    end


-- Обработка emagDynamicRecipes  
    -- Обработка emagDynamicRecipes  
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagDynamicRecipes then
    if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagDynamicRecipes then
    for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagDynamicRecipes) do
        for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagDynamicRecipes) do
        local recipe = getRecipeDetails(recipeId)
            local recipe = getRecipeDetails(recipeId)
        if recipe then
            if recipe then
            local researchInfo = findInResearch(recipeId)
                local researchInfo = findInResearch(recipeId)
            if researchInfo then
                if researchInfo then
                table.insert(recipes, {
                    table.insert(recipes, {
                    result = recipe.result,
                        result = recipe.result,
                    completetime = recipe.completetime,
                        completetime = recipe.completetime,
                    materials = recipe.materials,
                        materials = recipe.materials,
                    discipline = researchInfo.discipline, -- Discipline из исследования
                        discipline = researchInfo.discipline,
                    tier = researchInfo.tier, -- Уровень из исследования
                        tier = researchInfo.tier,
                    researchName = researchInfo.name,
                        researchName = researchInfo.name,
                    isEmag = true -- Флаг для пометки EMAG
                        isEmag = true
                })
                    })
            else
                else
                table.insert(recipes, {
                    table.insert(recipes, {
                    result = recipe.result,
                        result = recipe.result,
                    completetime = recipe.completetime,
                        completetime = recipe.completetime,
                    materials = recipe.materials,
                        materials = recipe.materials,
                    discipline = "Unknown", -- Если нет информации об исследовании
                        discipline = "Unknown",
                    tier = 0,
                        tier = 0,
                    isEmag = true -- Флаг для пометки EMAG
                        isEmag = true
                })
                    })
            end
                end
        end
            end
    end
        end
end
    end
-- Вывод рецептов
for _, recipe in ipairs(recipes) do
    output = output .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result
    output = output .. '|complete-time=' .. format_seconds_to_short_string(recipe.completetime)
    output = output .. '|materials='
    for material, amount in pairs(recipe.materials) do
        output = output .. '<li>' .. material .. ': ' .. amount .. '</li>'
    end


    -- Информация об исследовании
    -- Сортируем рецепты
    if recipe.discipline ~= "Static" and recipe.discipline ~= "Unknown" then
    sortRecipesByPriority(recipes)
        output = output .. '|info=Исследование: ' .. recipe.discipline .. ' - ' .. recipe.researchName
        output = output .. ' (Уровень: ' .. recipe.tier .. ')'
    end
   
    -- Пометка EMAG
    if recipe.isEmag then
        output = output .. '<div>Пометка: EMAG</div>'
    end
end


output = output .. '}}'
    -- Вывод рецептов
    for _, recipe in ipairs(recipes) do
        output = output .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result
        output = output .. '|complete-time=' .. format_seconds_to_short_string(recipe.completetime)
        output = output .. '|materials='
 
        if next(recipe.materials) then
            for material, amount in pairs(recipe.materials) do
                output = output .. '<li>' .. material .. ': ' .. amount .. '</li>'
            end
        else
            output = output .. 'Нет данных о материалах'
        end
 
        -- Информация об исследовании
        if recipe.discipline ~= "Static" and recipe.discipline ~= "Unknown" then
            output = output .. '|info=Исследование: ' .. recipe.discipline .. ' - ' .. recipe.researchName
            output = output .. ' (Уровень: ' .. recipe.tier .. ')'
        end
       
        -- Пометка EMAG
        if recipe.isEmag then
            output = output .. '<div>Пометка: EMAG</div>'
        end
 
        output = output .. '}}'
    end


     return mw.getCurrentFrame():preprocess(output)
     return mw.getCurrentFrame():preprocess(output)