Модуль:tableofchemicals

Вернуться

Строка 44: Строка 44:
templateArgs.actions = getActions(reactPrototype)
templateArgs.actions = getActions(reactPrototype)
-- Берем данные из первого реагента (если есть)
local chemData = nil
local firstReactantId, firstReactantValue = next(reactPrototype.reactants)
local firstReactantId, firstReactantValue = next(reactPrototype.reactants)
if firstReactantId and p.chem[firstReactantId] then
if firstReactantId and p.chem[firstReactantId] then
local chemData = p.chem[firstReactantId]
chemData = p.chem[firstReactantId]
else
local firstProductId, firstProductAmount = next(reactPrototype.products)
if firstProductId and p.chem[firstProductId] then
chemData = p.chem[firstProductId]
end
end
if chemData then
templateArgs.name = chemData.name or ""
templateArgs.name = chemData.name or ""
templateArgs.color = chemData.color or "#808080"
templateArgs.color = chemData.color or "#808080"
templateArgs.textColor = chemData.textColor or "#FFFFFF"
templateArgs.textColor = chemData.textColor or "#FFFFFF"
templateArgs.id = chemData.id or ""
else
else
-- Если реагентов нет, берем из первого продукта
templateArgs.name = ""
local firstProductId, firstProductAmount = next(reactPrototype.products)
templateArgs.color = "#808080"
if firstProductId and p.chem[firstProductId] then
templateArgs.textColor = "#FFFFFF"
local chemData = p.chem[firstProductId]
templateArgs.name = chemData.name or ""
templateArgs.color = chemData.color or "#808080"
templateArgs.textColor = chemData.textColor or "#FFFFFF"
templateArgs.id = chemData.id or ""
else
-- Если ничего нет - значения по умолчанию
templateArgs.name = "Неизвестно"
templateArgs.color = "#808080"
templateArgs.textColor = "#FFFFFF"
templateArgs.id = "unknown"
end
end
end
-- Все остальные данные из reactPrototype
templateArgs.id = reactPrototype.id or ""
local template = "Строка_реакции"
local template = "Строка_реакции"