Модуль:Prototypes/Механика/Исследование: различия между версиями

мНет описания правки
мНет описания правки
Строка 85: Строка 85:
-- Получение кастомных рецептов с индексами (если они есть)
-- Получение кастомных рецептов с индексами (если они есть)
local customRecipeUnlocks = {}
local customRecipeUnlocks = {}
for i = 1, 10 do -- Проверяем до 10 индексов
for i = 1, 100 do  
local indexKey = "customRecipeUnlocksIndex" .. i
local indexKey = "customRecipeUnlocksIndex" .. i
if frame.args[indexKey] then
if frame.args[indexKey] then
Строка 94: Строка 94:
-- Получение кастомных рецептов без индексации
-- Получение кастомных рецептов без индексации
if frame.args.customRecipeUnlocks then
if frame.args.customRecipeUnlocks then
-- Разделяем на несколько значений, если они переданы через пробел
local tempUnlocks = mw.text.split(frame.args.customRecipeUnlocks, " ")
local tempUnlocks = mw.text.split(frame.args.customRecipeUnlocks, " ")
for _, item in ipairs(tempUnlocks) do
for _, item in ipairs(tempUnlocks) do
Строка 116: Строка 115:
out = out .. '<div class="research__technology">' .. disciplineName .. '</div>'
out = out .. '<div class="research__technology">' .. disciplineName .. '</div>'
out = out .. '<div>Стоимость: <span style="color:#DA70D6;">' .. tech.cost .. '</span></div>'
out = out .. '<div>Стоимость: <span style="color:#DA70D6;">' .. tech.cost .. '</span></div>'
out = out .. '</div>'
out = out .. '<div class="research__unblocks">Разблокирует:'
out = out .. '<ul>'
for _, recipe in ipairs(tech.technologyPrerequisites) do
out = out .. frame:preprocess('<li>{{#invoke:Entity Lookup|createimagetooltip|Файл:' .. tech.technologyPrerequisites .. '.png|' .. tech.technologyPrerequisites .. '|Мета=32x32px,link=}} {{#invoke:Entity Lookup|getname|' .. tech.technologyPrerequisites .. '}}</li>')
end
out = out .. '</ul>'
out = out .. '</div>'
out = out .. '</div>'
out = out .. '<div class="research__unblocks">Разблокирует:'
out = out .. '<div class="research__unblocks">Разблокирует:'
Строка 123: Строка 129:
local recipeUnlocks = customRecipeUnlocks
local recipeUnlocks = customRecipeUnlocks
if #customRecipeUnlocks == 0 then
if #customRecipeUnlocks == 0 then
-- Если кастомных рецептов нет, используем стандартные из JSON
recipeUnlocks = tech.recipeUnlocks
recipeUnlocks = tech.recipeUnlocks
end
end