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

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


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


Строка 308: Строка 308:
         local materialUseMultiplier = (lathe.Lathe and lathe.Lathe.materialUseMultiplier) or 1
         local materialUseMultiplier = (lathe.Lathe and lathe.Lathe.materialUseMultiplier) or 1
         local timeMultiplier = (lathe.Lathe and lathe.Lathe.timeMultiplier) or 1
         local timeMultiplier = (lathe.Lathe and lathe.Lathe.timeMultiplier) or 1
        local matchingRecipes = {}


         for _, recipe in ipairs(recipes) do
         for _, recipe in ipairs(recipes) do
             if recipe.id == itemId or recipe.result == itemId then
             if recipe.id == itemId or recipe.result == itemId then
                 foundAny = true
                 table.insert(matchingRecipes, recipe)
                out = out .. '|-' .. "\n"
                out = out .. '| ' .. formatRecipe(recipe, timeMultiplier, materialUseMultiplier, true) .. "\n"
                out = out .. '| [[File:' .. lathe.id .. '.png|32x32px|link=]] [[{{#invoke:Entity Lookup|getname|' .. lathe.id .. '}}|{{#invoke:Entity Lookup|getname|' .. lathe.id .. '}}]]' .. "\n"
             end
             end
        end
        if #matchingRecipes > 0 then
            foundAny = true
            out = out .. '<div class="lathe-grid">'
            for _, recipe in ipairs(matchingRecipes) do
                -- Формируем строку рецепта без параметра no-product (itemMode = false)
                local recipeStr = formatRecipe(recipe, timeMultiplier, materialUseMultiplier, false)
                -- Добавляем параметр method-container с id станка
                recipeStr = recipeStr:gsub("}}$", "|method-container=" .. lathe.id .. "}}")
                out = out .. recipeStr
            end
            out = out .. '</div>'
         end
         end
     end
     end
Строка 323: Строка 334:
     end
     end


    out = out .. '|}'
     return mw.getCurrentFrame():preprocess(out)
     return mw.getCurrentFrame():preprocess(out)
end
end
Строка 336: Строка 346:
     end
     end


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


Строка 358: Строка 368:
         if #matchingRecipes > 0 then
         if #matchingRecipes > 0 then
             foundAny = true
             foundAny = true
             local rowspan = #matchingRecipes
             out = out .. '<div class="lathe-grid">'
             for i, recipe in ipairs(matchingRecipes) do
             for _, recipe in ipairs(matchingRecipes) do
                 out = out .. '|-\n'
                 local recipeStr = formatRecipe(recipe, timeMultiplier, materialUseMultiplier, false)
                out = out .. '| ' .. formatRecipe(recipe, timeMultiplier, materialUseMultiplier, false) .. "\n"
                 recipeStr = recipeStr:gsub("}}$", "|method-container=" .. lathe.id .. "}}")
                 if i == 1 then
                 out = out .. recipeStr
                    out = out .. string.format('| rowspan="%d"|[[File:%s.png|32x32px|link=]] [[{{#invoke:Entity Lookup|getname|%s}}|{{#invoke:Entity Lookup|getname|%s}}]]\n', rowspan, lathe.id, lathe.id, lathe.id)
                 end
             end
             end
            out = out .. '</div>'
         end
         end
     end
     end
Строка 373: Строка 382:
     end
     end


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


return p
return p