Модуль:Prototypes/Механика/Исследование: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 78: | Строка 78: | ||
local icon = frame.args.icon or "" | local icon = frame.args.icon or "" | ||
local customRecipeUnlocks = frame.args.customRecipeUnlocks or nil | local customRecipeUnlocks = frame.args.customRecipeUnlocks or nil | ||
-- Обрабатываем индексы для замены рецептов | |||
local customRecipeUnlocksIndexes = {} | |||
for i = 1, 10 do | |||
local customIndex = frame.args["customRecipeUnlocksIndex" .. i] | |||
if customIndex then | |||
table.insert(customRecipeUnlocksIndexes, {index = i, recipe = customIndex}) | |||
end | |||
end | |||
-- Загружаем данные исследований из кэша | -- Загружаем данные исследований из кэша | ||
| Строка 117: | Строка 126: | ||
-- Используем кастомные recipeUnlocks или значения из json файла | -- Используем кастомные recipeUnlocks или значения из json файла | ||
local recipeUnlocks = customRecipeUnlocks and mw.text.split(customRecipeUnlocks, " ") or tech.recipeUnlocks | local recipeUnlocks = customRecipeUnlocks and mw.text.split(customRecipeUnlocks, " ") or tech.recipeUnlocks | ||
-- Замена рецептов по индексам | |||
for _, customIndex in ipairs(customRecipeUnlocksIndexes) do | |||
if recipeUnlocks[customIndex.index] then | |||
recipeUnlocks[customIndex.index] = customIndex.recipe | |||
end | |||
end | |||
for _, recipe in ipairs(recipeUnlocks) do | for _, recipe in ipairs(recipeUnlocks) do | ||
| Строка 137: | Строка 153: | ||
return out | return out | ||
end | end | ||