Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 80: | Строка 80: | ||
end | end | ||
-- Вспомогательная функция для обработки одного рецепта | |||
local function processRecipe(recipeId, defaultDiscipline, isEmag) | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe then | |||
if recipe.result then | |||
local info = { | |||
id = recipe.id, | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = defaultDiscipline, | |||
tier = 0, | |||
isEmag = isEmag or false | |||
} | |||
if defaultDiscipline ~= "Static" then | |||
local researchInfo = findInResearch(recipeId) | |||
if researchInfo then | |||
info.discipline = researchInfo.discipline | |||
info.tier = researchInfo.tier | |||
info.researchName = researchInfo.name | |||
end | |||
end | |||
table.insert(recipes, info) | |||
elseif recipe.resultReagents then | |||
for reagent, amount in pairs(recipe.resultReagents) do | |||
local reagentName = chemMapping[reagent] or reagent | |||
table.insert(recipes, { | |||
id = recipe.id, | |||
result = reagentName .. "|amount=" .. amount .. "ед.|mode-chem=1", | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = defaultDiscipline, | |||
tier = 0, | |||
isEmag = isEmag or false | |||
}) | |||
break | |||
end | |||
end | |||
end | |||
end | |||
-- Обработка рецептов для lathe.Lathe (старый и новый формат) | -- Обработка рецептов для lathe.Lathe (старый и новый формат) | ||
| Строка 308: | Строка 310: | ||
for _, recipe in ipairs(recipes) do | for _, recipe in ipairs(recipes) do | ||
if recipe.result == itemId then | if recipe.id == itemId or recipe.result == itemId then | ||
foundAny = true | foundAny = true | ||
out = out .. '|-' .. "\n" | out = out .. '|-' .. "\n" | ||