Модуль:tableofchemicals

Вернуться

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