Модуль:Песочница/Pok: различия между версиями

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


     local out = ""
     local out = '{| class="wikitable"\n! Станок ID\n! Рецепт\n'
     local foundAny = false
     local foundAny = false


     for _, lathe in ipairs(latheData) do
     for _, lathe in ipairs(latheData) do
         local recipes = getLatheRecipes(lathe)
         local recipes = getLatheRecipes(lathe)
         local matchingRecipes = {}
         local materialUseMultiplier = (lathe.Lathe and lathe.Lathe.materialUseMultiplier) or 1
        local timeMultiplier = (lathe.Lathe and lathe.Lathe.timeMultiplier) or 1
 
         for _, recipe in ipairs(recipes) do
         for _, recipe in ipairs(recipes) do
             if recipe.result == itemId then
             if recipe.result == itemId then
                 table.insert(matchingRecipes, recipe)
                 foundAny = true
            end
                out = out .. '|-\n'
        end
                out = out .. '| ' .. lathe.id .. '\n'
 
                 out = out .. '| ' .. formatRecipe(recipe, timeMultiplier, materialUseMultiplier) .. '\n'
        if #matchingRecipes > 0 then
            foundAny = true
            out = out .. '<div style="font-weight:bold;">Станок ID: ' .. lathe.id .. '</div>'
            local materialUseMultiplier = (lathe.Lathe and lathe.Lathe.materialUseMultiplier) or 1
            local timeMultiplier = (lathe.Lathe and lathe.Lathe.timeMultiplier) or 1
 
            for _, recipe in ipairs(matchingRecipes) do
                 out = out .. formatRecipe(recipe, timeMultiplier, materialUseMultiplier)
             end
             end
         end
         end
Строка 321: Строка 315:


     if not foundAny then
     if not foundAny then
         out = '<div style="color:red;">Рецепт для предмета с ID "' .. itemId .. '" не найден во всех станках.</div>'
         return '<div style="color:red;">Рецепт для предмета с ID "' .. itemId .. '" не найден во всех станках.</div>'
     end
     end


    out = out .. '|}'
     return mw.getCurrentFrame():preprocess(out)
     return mw.getCurrentFrame():preprocess(out)
end
end


return p
return p