Модуль:TableOfChemicals: различия между версиями
Материал из Space Station 14 Вики
мНет описания правки |
мНет описания правки |
||
Строка 17: | Строка 17: | ||
templateArgs.name = chemPrototype.name | templateArgs.name = chemPrototype.name | ||
templateArgs.description = chemPrototype.desc .. " На вид " .. chemPrototype.physicalDesc .. "." | templateArgs.description = chemPrototype.desc .. " На вид " .. chemPrototype.physicalDesc .. "." | ||
templateArgs.effects = getEffects(chemPrototype | templateArgs.effects = getEffects(chemPrototype) | ||
templateArgs.recipes_count = tablelength(chemPrototype.recipes) | templateArgs.recipes_count = tablelength(chemPrototype.recipes) | ||
Строка 61: | Строка 61: | ||
p.fillEffectsTable = function(frame) | p.fillEffectsTable = function(frame) | ||
end | end | ||
Строка 70: | Строка 69: | ||
end | end | ||
function getEffects( | function getEffects(chemPrototype) | ||
local effects = {} | |||
local effect = {} | |||
effect.condition = "Очень жарко" | |||
effect.effect = "+1 к хилке" | |||
table.insert(effects, effect) | |||
end | end | ||
return p | return p |
Версия от 22:36, 23 апреля 2024
Для документации этого модуля может быть создана страница Модуль:TableOfChemicals/doc
p = {} local prototypes = mw.loadData("Module:Chemistry Lookup/data") p.chem = prototypes.chem p.react = prototypes.react p.fillTable = function(frame) local out = {} local out = "" local group = frame.args.group local templateArgs = {} for _, chemPrototype in pairs(p.chem) do if group == nil or chemPrototype.group == group then templateArgs.name = chemPrototype.name templateArgs.description = chemPrototype.desc .. " На вид " .. chemPrototype.physicalDesc .. "." templateArgs.effects = getEffects(chemPrototype) templateArgs.recipes_count = tablelength(chemPrototype.recipes) local firstReact = true for _, reactId in pairs(chemPrototype.recipes) do local reactPrototype = p.react[reactId] local reactants = {} for reactantId, reactantValue in pairs(reactPrototype.reactants) do local reactantChemData = p.chem[reactantId] local reactantText = reactantValue.amount .. " " .. reactantChemData.name table.insert(reactants, reactantText) end templateArgs.reactants = table.concat(reactants, "<br>") local products = {} for productId, productAmount in pairs(reactPrototype.products) do local productChemData = p.chem[productId] local productText = productAmount .. " " .. productChemData.name table.insert(products, productText) end templateArgs.products = table.concat(products, "<br>") templateArgs.action = "смешать" local template = "Строка_химического_вещества" if firstReact then template = "Первая_строка_химического_вещества" firstReact = false end out = out .. frame:expandTemplate{ title = template, args = templateArgs} end end end return out end p.fillEffectsTable = function(frame) end function tablelength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end function getEffects(chemPrototype) local effects = {} local effect = {} effect.condition = "Очень жарко" effect.effect = "+1 к хилке" table.insert(effects, effect) end return p