Модуль:Prototypes/Машина/Станок: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 77: | Строка 77: | ||
end | end | ||
return nil | return nil | ||
end | end | ||
| Строка 223: | Строка 207: | ||
for _, packId in ipairs(lathe.Lathe.staticPacks) do | for _, packId in ipairs(lathe.Lathe.staticPacks) do | ||
local pack = getRecipePackDetails(packId) | local pack = getRecipePackDetails(packId) | ||
if pack then | if pack and pack.recipes then | ||
local packRecipes = | local packRecipes = pack.recipes | ||
if | if type(packRecipes) ~= "table" then | ||
for _, recipeId in ipairs(packRecipes) do | packRecipes = { packRecipes } | ||
end | |||
for _, recipeId in ipairs(packRecipes) do | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe and recipe.result then | |||
table.insert(recipes, { | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = "Static", | |||
tier = 0 | |||
}) | |||
elseif recipe and recipe.resultReagents then | |||
for reagent, amount in pairs(recipe.resultReagents) do | |||
local reagentName = chemMapping[reagent] or reagent | |||
table.insert(recipes, { | table.insert(recipes, { | ||
result = | result = reagentName .. "|amount=" .. amount .. "ед.|mode-chem=1", | ||
completetime = recipe.completetime, | completetime = recipe.completetime, | ||
materials = recipe.materials, | materials = recipe.materials, | ||
| Строка 236: | Строка 232: | ||
tier = 0 | tier = 0 | ||
}) | }) | ||
break | |||
end | end | ||
else | |||
out = out .. '<div style="color:red;">Ошибка: Рецепт с ID "' .. recipeId .. '" не найден или поля result/resultReagents отсутствуют.</div>' | |||
end | end | ||
end | end | ||
else | else | ||
out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден.</div>' | out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден или не содержит рецепты.</div>' | ||
end | end | ||
end | end | ||
| Строка 265: | Строка 248: | ||
for _, packId in ipairs(lathe.Lathe.dynamicPacks) do | for _, packId in ipairs(lathe.Lathe.dynamicPacks) do | ||
local pack = getRecipePackDetails(packId) | local pack = getRecipePackDetails(packId) | ||
if pack then | if pack and pack.recipes then | ||
local packRecipes = | local packRecipes = pack.recipes | ||
if | if type(packRecipes) ~= "table" then | ||
for _, recipeId in ipairs(packRecipes) do | packRecipes = { packRecipes } | ||
end | |||
for _, recipeId in ipairs(packRecipes) do | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe then | |||
local researchInfo = findInResearch(recipeId) | |||
if researchInfo then | |||
table.insert(recipes, { | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = researchInfo.discipline, | |||
tier = researchInfo.tier, | |||
researchName = researchInfo.name | |||
}) | |||
end | end | ||
end | end | ||
end | end | ||
else | else | ||
out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден.</div>' | out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден или не содержит рецепты.</div>' | ||
end | end | ||
end | end | ||
| Строка 297: | Строка 279: | ||
for _, packId in ipairs(lathe.EmagLatheRecipes.emagStaticPacks) do | for _, packId in ipairs(lathe.EmagLatheRecipes.emagStaticPacks) do | ||
local pack = getRecipePackDetails(packId) | local pack = getRecipePackDetails(packId) | ||
if pack then | if pack and pack.recipes then | ||
local packRecipes = | local packRecipes = pack.recipes | ||
if | if type(packRecipes) ~= "table" then | ||
for _, recipeId in ipairs(packRecipes) do | packRecipes = { packRecipes } | ||
end | |||
for _, recipeId in ipairs(packRecipes) do | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe then | |||
table.insert(recipes, { | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = "Static", | |||
tier = 0, | |||
isEmag = true | |||
}) | |||
end | end | ||
end | end | ||
else | else | ||
out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден.</div>' | out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден или не содержит рецепты.</div>' | ||
end | end | ||
end | end | ||
| Строка 326: | Строка 307: | ||
for _, packId in ipairs(lathe.EmagLatheRecipes.emagDynamicPacks) do | for _, packId in ipairs(lathe.EmagLatheRecipes.emagDynamicPacks) do | ||
local pack = getRecipePackDetails(packId) | local pack = getRecipePackDetails(packId) | ||
if pack then | if pack and pack.recipes then | ||
local packRecipes = | local packRecipes = pack.recipes | ||
if | if type(packRecipes) ~= "table" then | ||
for _, recipeId in ipairs(packRecipes) do | packRecipes = { packRecipes } | ||
end | |||
for _, recipeId in ipairs(packRecipes) do | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe then | |||
local researchInfo = findInResearch(recipeId) | |||
if researchInfo then | |||
table.insert(recipes, { | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials, | |||
discipline = researchInfo.discipline, | |||
tier = researchInfo.tier, | |||
researchName = researchInfo.name, | |||
isEmag = true | |||
}) | |||
end | end | ||
end | end | ||
end | end | ||
else | else | ||
out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден.</div>' | out = out .. '<div style="color:red;">Ошибка: Пакет рецептов с ID "' .. packId .. '" не найден или не содержит рецепты.</div>' | ||
end | end | ||
end | end | ||