Модуль:Prototypes/Машина/Станок: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 301: | Строка 301: | ||
end | end | ||
local out | 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 | ||
table.insert(matchingRecipes, recipe) | |||
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 | ||
return mw.getCurrentFrame():preprocess(out) | return mw.getCurrentFrame():preprocess(out) | ||
end | end | ||
| Строка 336: | Строка 346: | ||
end | end | ||
local out | local out = "" | ||
local foundAny = false | local foundAny = false | ||
| Строка 358: | Строка 368: | ||
if #matchingRecipes > 0 then | if #matchingRecipes > 0 then | ||
foundAny = true | foundAny = true | ||
out = out .. '<div class="lathe-grid">' | |||
for | for _, recipe in ipairs(matchingRecipes) do | ||
local recipeStr = formatRecipe(recipe, timeMultiplier, materialUseMultiplier, false) | |||
recipeStr = recipeStr:gsub("}}$", "|method-container=" .. lathe.id .. "}}") | |||
out = out .. recipeStr | |||
end | end | ||
out = out .. '</div>' | |||
end | end | ||
end | end | ||
| Строка 373: | Строка 382: | ||
end | end | ||
return mw.getCurrentFrame():preprocess(out) | return mw.getCurrentFrame():preprocess(out) | ||
end | end | ||
return p | return p | ||