Модуль:tableofchemicals
| Строка 9: | Строка 9: | ||
for _, reactPrototype in pairs(p.react) do | for _, reactPrototype in pairs(p.react) do | ||
local reactants = {} | local reactants = {} | ||
local reactantTemplate = "%s [[#chem_%s|%s]]" | |||
for reactantId, reactantValue in pairs(reactPrototype.reactants) do | for reactantId, reactantValue in pairs(reactPrototype.reactants) do | ||
local reactantChemData = p.chem[reactantId] | local reactantChemData = p.chem[reactantId] | ||
local reactantText = string.format(reactantTemplate, reactantValue.amount, reactantChemData.id, reactantChemData.name) | |||
local reactantText = string.format( | |||
if reactantValue.catalyst then | if reactantValue.catalyst then | ||
reactantText = reactantText .. " (катализатор)" | reactantText = reactantText .. " (катализатор)" | ||
| Строка 33: | Строка 24: | ||
local products = {} | local products = {} | ||
local productTemplate = "%s [[#chem_%s|%s]]" | |||
for productId, productAmount in pairs(reactPrototype.products) do | for productId, productAmount in pairs(reactPrototype.products) do | ||
local productChemData = p.chem[productId] | local productChemData = p.chem[productId] | ||
local productText = string.format(productTemplate, productAmount, productChemData.id, productChemData.name) | |||
local productText = string.format( | |||
table.insert(products, productText) | table.insert(products, productText) | ||
end | end | ||