Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
function p. | local borderColors = { | ||
gas = "#adff2f", | |||
liquid = "#1e88e5", | |||
solid = "#ff9800" | |||
} | |||
function p.render(frame) | |||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local name = args.name or | local type = args.type or "gas" | ||
local | local name = args.name or "Название" | ||
local | local description = args.description or "Краткое описание" | ||
local | local recipes = mw.text.split(args.recipes or "", "\n") | ||
local | local effects = mw.text.split(args.effects or "", "\n") | ||
local recipe = | |||
local container = mw.html.create("div") | |||
:addClass("recipe-block") | |||
:addClass(type) | |||
:css("border-left", "4px solid " .. (borderColors[type] or "#999")) | |||
container:tag("div") | |||
:addClass("recipe-name") | |||
:wikitext(name) | |||
-- Рецепты | |||
local recipeSection = container:tag("div"):addClass("recipe-section") | |||
recipeSection:tag("div") | |||
:addClass("section-title") | |||
:attr("onclick", "toggleSection(this)") | |||
:wikitext("Рецепты") | |||
local recipeContent = recipeSection:tag("div"):addClass("section-content") | |||
for _, line in ipairs(recipes) do | |||
if line ~= "" then | |||
local parts = mw.text.split(line, "=>") | |||
local output = mw.text.trim(parts[1] or "?") | |||
local inputs = mw.text.trim(parts[2] or "?") | |||
local recipeItem = recipeContent:tag("div"):addClass("recipe-item") | |||
recipeItem:tag("div"):addClass("output"):wikitext(output) | |||
recipeItem:tag("div"):addClass("ingredients"):wikitext("Смешайте:<br>" .. inputs) | |||
end | |||
end | |||
-- Эффекты | |||
local effectSection = container:tag("div"):addClass("effect-section") | |||
effectSection:tag("div") | |||
:addClass("section-title") | |||
:attr("onclick", "toggleSection(this)") | |||
:wikitext("Эффекты") | |||
local | local effectContent = effectSection:tag("div"):addClass("section-content") | ||
for _, effect in ipairs(effects) do | |||
if effect ~= "" then | |||
effectContent:tag("div"):addClass("effect"):wikitext(effect) | |||
end | |||
end | end | ||
-- Описание | |||
container:tag("div"):addClass("description"):wikitext(description) | |||
return | return tostring(container) | ||
end | end | ||
return p | return p | ||
Версия от 02:54, 17 июня 2025
Для документации этого модуля может быть создана страница Модуль:AlchemyRecipe/doc
local p = {}
local borderColors = {
gas = "#adff2f",
liquid = "#1e88e5",
solid = "#ff9800"
}
function p.render(frame)
local args = frame:getParent().args
local type = args.type or "gas"
local name = args.name or "Название"
local description = args.description or "Краткое описание"
local recipes = mw.text.split(args.recipes or "", "\n")
local effects = mw.text.split(args.effects or "", "\n")
local container = mw.html.create("div")
:addClass("recipe-block")
:addClass(type)
:css("border-left", "4px solid " .. (borderColors[type] or "#999"))
container:tag("div")
:addClass("recipe-name")
:wikitext(name)
-- Рецепты
local recipeSection = container:tag("div"):addClass("recipe-section")
recipeSection:tag("div")
:addClass("section-title")
:attr("onclick", "toggleSection(this)")
:wikitext("Рецепты")
local recipeContent = recipeSection:tag("div"):addClass("section-content")
for _, line in ipairs(recipes) do
if line ~= "" then
local parts = mw.text.split(line, "=>")
local output = mw.text.trim(parts[1] or "?")
local inputs = mw.text.trim(parts[2] or "?")
local recipeItem = recipeContent:tag("div"):addClass("recipe-item")
recipeItem:tag("div"):addClass("output"):wikitext(output)
recipeItem:tag("div"):addClass("ingredients"):wikitext("Смешайте:<br>" .. inputs)
end
end
-- Эффекты
local effectSection = container:tag("div"):addClass("effect-section")
effectSection:tag("div")
:addClass("section-title")
:attr("onclick", "toggleSection(this)")
:wikitext("Эффекты")
local effectContent = effectSection:tag("div"):addClass("section-content")
for _, effect in ipairs(effects) do
if effect ~= "" then
effectContent:tag("div"):addClass("effect"):wikitext(effect)
end
end
-- Описание
container:tag("div"):addClass("description"):wikitext(description)
return tostring(container)
end
return p