Модуль:tableofchemicals
| Строка 44: | Строка 44: | ||
templateArgs.actions = getActions(reactPrototype) | templateArgs.actions = getActions(reactPrototype) | ||
templateArgs.name = | -- Берем данные из первого реагента (если есть) | ||
local firstReactantId, firstReactantValue = next(reactPrototype.reactants) | |||
if firstReactantId and p.chem[firstReactantId] then | |||
templateArgs.id = | 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 = "Строка_реакции" | ||