Модуль:Prototypes/Машина/Станок: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 36: | Строка 36: | ||
-- Функция для сортировки рецептов | -- Функция для сортировки рецептов | ||
local function | local function sortRecipesByDisciplineAndTier(recipes) | ||
table.sort(recipes, function(a, b) | table.sort(recipes, function(a, b) | ||
if a.discipline == b.discipline then | |||
return a.tier < b.tier | |||
end | end | ||
return | return a.discipline < b.discipline | ||
end) | end) | ||
end | end | ||
| Строка 78: | Строка 71: | ||
local recipes = {} | local recipes = {} | ||
local emagRecipes = {} | |||
local function getRecipeDetails(recipeId) | local function getRecipeDetails(recipeId) | ||
| Строка 145: | Строка 139: | ||
}) | }) | ||
end | end | ||
end | |||
end | |||
end | |||
-- Обработка emagStaticRecipes | |||
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagStaticRecipes then | |||
for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagStaticRecipes) do | |||
local recipe = getRecipeDetails(recipeId) | |||
if recipe then | |||
table.insert(emagRecipes, { | |||
result = recipe.result, | |||
completetime = recipe.completetime, | |||
materials = recipe.materials | |||
}) | |||
end | end | ||
end | end | ||
| Строка 150: | Строка 158: | ||
-- Сортировка рецептов | -- Сортировка рецептов | ||
sortRecipesByDisciplineAndTier(recipes) | |||
-- Вывод рецептов | -- Вывод рецептов | ||
| Строка 166: | Строка 174: | ||
end | end | ||
output = output .. '</li>' | output = output .. '</li>' | ||
end | |||
-- Вывод emagStaticRecipes | |||
if #emagRecipes > 0 then | |||
output = output .. '<li><strong>Дополнительный ассортимент (EMAG):</strong></li>' | |||
for _, recipe in ipairs(emagRecipes) do | |||
output = output .. '<li>' .. recipe.result | |||
output = output .. ' (Время изготовления: ' .. format_seconds_to_short_string(recipe.completetime) .. ')' | |||
output = output .. '<ul>' | |||
for material, amount in pairs(recipe.materials) do | |||
output = output .. '<li>' .. material .. ': ' .. amount .. '</li>' | |||
end | |||
output = output .. '</ul>' | |||
output = output .. '<div><strong>EMAG</strong></div>' | |||
output = output .. '</li>' | |||
end | |||
end | end | ||