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