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

мНет описания правки
мНет описания правки
Строка 4: Строка 4:
p.chem = prototypes.chem
p.chem = prototypes.chem
p.react = prototypes.react
p.react = prototypes.react
p.test = function()
mw.log(tablelength(p.chem["Bicaridine"].recipes))
end


p.fillTable = function(frame)
p.fillTable = function(frame)
Строка 39: Строка 33:
local reactPrototype = p.react[reactId]
local reactPrototype = p.react[reactId]
local reactants = {}
local reactants = {}
local reactantTemplateWithLink = "%s [[#%s|%s]]"
local reactantTemplate = "%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
local reactantText = string.format(reactantTemplate, reactantValue.amount, reactantChemData.id,  reactantChemData.name)
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
Строка 86: Строка 75:
p.fillEffectsTable = function(frame)
p.fillEffectsTable = function(frame)
--Временно заполняем старым описанием эфектов
local chemPrototypeId = frame.args.id
local chemPrototypeId = frame.args.id
 
return p.geneffects(chemPrototypeId)
local out = "{|" -- Объявление таблицы (Условие | Эффект)
[[local out = "{|" -- Объявление таблицы (Условие | Эффект)
local rowTemplate = "|-\n| %s || %s" -- Шаблон строки таблицы
local rowTemplate = "|-\n| %s || %s" -- Шаблон строки таблицы
Строка 99: Строка 90:
out = attachAsNewLine(out, "|}") -- Конец таблицы
out = attachAsNewLine(out, "|}") -- Конец таблицы
mw.log(out)
mw.log(out)
return out
return out]]
end
 
function makeALink(group, linkId)
chemPrototype = p.chem[linkId]
if chemPrototype == nil then -- Не на что ссылаться
return false
end
return true
end
end