Модуль:TableOfChemicals: различия между версиями

мНет описания правки
мНет описания правки
Строка 25: Строка 25:
local reactPrototype = p.react[reactId]
local reactPrototype = p.react[reactId]
local reactants = {}
local reactants = {}
local reactantTemplate = "%s [[#%s|%s]]"
local reactantTemplateWithLink = "%s [[#%s|%s]]"
local reactantTemplate = "%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
if makeALink(group, reactantChemData.id) then
reactantText = string.format(reactantTemplateWithLink, reactantValue.amount, reactantChemData.id,  reactantChemData.name)
else
reactantText = string.format(reactantTemplate, reactantValue.amount,  reactantChemData.name)
end
table.insert(reactants, reactantText)
table.insert(reactants, reactantText)
end
end
Строка 78: Строка 84:
return out
return out
end
function makeALink(group, linkId)
chemPrototype = p.chem[linkId]
if chemPrototype == nil then -- Не на что ссылаться
return false
end
return true
end
end