Модуль:Prototypes/Механика/Исследование: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 50: | Строка 50: | ||
}) | }) | ||
local id = frame.args.id or "" | local id = frame.args.id or "" -- ID исследования | ||
local icon = frame.args.icon or "" | local icon = frame.args.icon or "" -- Изобрадения исследования | ||
local customRecipeUnlocks = frame.args.recipeUnlocks or nil -- Ручной ввод в список разблокируемых технологий | |||
-- Загрузка данных из JSON | -- Загрузка данных из JSON | ||
| Строка 79: | Строка 80: | ||
})[tech.tier] | })[tech.tier] | ||
-- Формирование HTML | -- Формирование HTML | ||
out = out .. '<div class="research" id="' .. discipline .. '">' | out = out .. '<div class="research" id="' .. discipline .. '">' | ||
out = out .. '<div class="research__images">[[Файл:' .. icon .. '.png|64x64px|центр|link=]]</div>' -- Используем переданный icon | out = out .. '<div class="research__images">[[Файл:' .. icon .. '.png|64x64px|центр|link=]]</div>' -- Используем переданный icon | ||
| Строка 90: | Строка 91: | ||
out = out .. '<div class="research__unblocks">Разблокирует:' | out = out .. '<div class="research__unblocks">Разблокирует:' | ||
out = out .. '<ul>' | out = out .. '<ul>' | ||
-- Используем пользовательские recipeUnlocks, если они указаны, иначе используем значения из json файла | |||
local recipeUnlocks | |||
if customRecipeUnlocks then | |||
recipeUnlocks = mw.text.split(customRecipeUnlocks, " ") -- Разбиваем по пробелам | |||
else | |||
recipeUnlocks = tech.recipeUnlocks | |||
end | |||
-- Проверка каждого ID в recipeUnlocks | -- Проверка каждого ID в recipeUnlocks | ||
for _, recipe in ipairs( | for _, recipe in ipairs(recipeUnlocks) do | ||
local machineID = translateBoardIDToMachineID(recipe) or recipe -- Переводим только платы, остальные оставляем как есть | local machineID = translateBoardIDToMachineID(recipe) or recipe -- Переводим только платы, остальные оставляем как есть | ||
| Строка 106: | Строка 115: | ||
if not found then | if not found then | ||
out = out .. '<div>Нет доступных | out = out .. '<div>Нет доступных исследований.</div>' | ||
end | end | ||