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

Материал из Space Stories Wiki
Нет описания правки
(Полностью удалено содержимое страницы)
Метки: очистка ручная отмена
 
(не показано 13 промежуточных версий этого же участника)
Строка 1: Строка 1:
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

Текущая версия от 11:41, 22 июня 2025

Для документации этого модуля может быть создана страница Модуль:AlchemyRecipe/doc