Модуль:tableofchemicals
| Строка 8: | Строка 8: | ||
for _, reactPrototype in pairs(p.react) do | for _, reactPrototype in pairs(p.react) do | ||
local | local reactants = {} | ||
local reactantTemplate = "%s [[#chem_%s|%s]]" | |||
for reactantId, reactantValue in pairs(reactPrototype.reactants) do | |||
for | local reactantChemData = p.chem[reactantId] | ||
local reactantText = string.format(reactantTemplate, reactantValue.amount, reactantChemData.id, reactantChemData.name) | |||
if reactantValue.catalyst then | |||
reactantText = reactantText .. " (катализатор)" | |||
end | end | ||
table.insert(reactants, reactantText) | |||
end | end | ||
local templateArgs = {} | |||
templateArgs.reactants = table.concat(reactants, "<br>") | |||
local products = {} | |||
local productTemplate = "%s [[#chem_%s|%s]]" | |||
for productId, productAmount in pairs(reactPrototype.products) do | |||
local productChemData = p.chem[productId] | |||
local | local productText = string.format(productTemplate, productAmount, productChemData.id, productChemData.name) | ||
table.insert(products, productText) | |||
end | |||
-- Эффекты реакции | |||
if tablelength(reactPrototype.effects) then | |||
for _, effect in pairs(reactPrototype.effects) do | |||
if effect.description ~= "" then | |||
table.insert(products, effect.description) | |||
for | |||
if | |||
table.insert( | |||
end | end | ||
end | end | ||
end | end | ||
templateArgs.products = table.concat(products, "<br>") | |||
templateArgs.actions = getActions(reactPrototype) | |||
local template = "Строка_реакции" | |||
out = out .. frame:expandTemplate{ title = template, args = templateArgs} | |||
end | end | ||
return out | return out | ||
| Строка 202: | Строка 171: | ||
end | end | ||
-- Эффекты реакции | -- Эффекты реакции | ||
if | if tablelength(reactPrototype.effects) then | ||
for _, effect in pairs(reactPrototype.effects) do | for _, effect in pairs(reactPrototype.effects) do | ||
if effect.description ~= "" then | if effect.description ~= "" then | ||
| Строка 229: | Строка 198: | ||
local actions = {} | local actions = {} | ||
for _, mixingCategory in pairs(reactPrototype.mixingCategories) do | |||
local image = getMixingImage(mixingCategory.id) | |||
if image ~= nil then | |||
table.insert(actions, string.format("[[File:%s|32px|link=]]", image)) -- Картинка | |||
end | end | ||
table.insert(actions, mixingCategory.name or mixingCategory.id) -- Название | |||
end | end | ||