Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) (Отмена правки 19156, сделанной Dantes (обсуждение)) Метка: отмена |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local function | local darkColors = { | ||
local | border = "#338833", | ||
for | bg = "#1a2a1a", | ||
table.insert( | border2 = "#cc7744", | ||
bg2 = "#2a1a12", | |||
border3 = "#2277cc", | |||
bg3 = "#121a26" | |||
} | |||
local function renderIngredients(ingredients) | |||
local parts = {} | |||
for _, item in ipairs(ingredients) do | |||
table.insert(parts, mw.html.create("div"):wikitext(item):allDone()) | |||
end | end | ||
return | return table.concat(parts, "\n") | ||
end | |||
local function renderEffect(text) | |||
return mw.html.create("div"):addClass("alchemy-effect"):wikitext(text):allDone() | |||
end | |||
local function renderRecipe(text) | |||
return mw.html.create("div"):addClass("alchemy-recipe-block"):wikitext(text):allDone() | |||
end | end | ||
function p. | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local ingredients = {} | |||
for k,v in pairs(args) do | |||
if k:match("^ingredient%d*$") then | |||
table.insert(ingredients, v) | |||
end | |||
end | |||
local | local result = args.result or "?" | ||
local effect = args.effect or "" | |||
local recipe = args.recipe or "" | |||
local | |||
local | |||
local | local html = mw.html.create("div") | ||
:addClass("alchemy-card") | |||
local | local content = mw.html.create("div") | ||
:addClass( | :addClass("alchemy-content") | ||
:css( | :css("display", "flex") | ||
:css( | :css("justify-content", "center") | ||
:css("align-items", "center") | |||
-- Левая колонка: ингредиенты вертикально | |||
local left = mw.html.create("div") | |||
:addClass("alchemy-ingredients") | |||
:css("display", "flex") | |||
:css("flex-direction", "column") | |||
:css("gap", "6px") | |||
:css("min-width", "150px") | |||
:wikitext(renderIngredients(ingredients)) | |||
local | -- Центр: слово Смешайте | ||
local center = mw.html.create("div") | |||
:addClass("alchemy-mix") | |||
:css("margin", "0 20px") | |||
:css("font-weight", "bold") | |||
:css("color", darkColors.border) | |||
:wikitext("Смешайте") | |||
-- Правая колонка: результат | |||
local right = mw.html.create("div") | |||
:addClass("alchemy-result") | |||
:css("display", "flex") | |||
:css("flex-direction", "column") | |||
:css("gap", "10px") | |||
right:node(mw.html.create("div"):addClass("alchemy-result-name"):wikitext(result)) | |||
if effect ~= "" then | |||
right:node(mw.html.create("div"):addClass("alchemy-effect-block"):wikitext(effect)) | |||
end | end | ||
if | if recipe ~= "" then | ||
right:node(mw.html.create("div"):addClass("alchemy-recipe-block"):wikitext(recipe)) | |||
end | end | ||
return tostring( | content | ||
:node(left) | |||
:node(center) | |||
:node(right) | |||
html | |||
:node(content) | |||
return tostring(html) | |||
end | end | ||
return p | return p | ||
Версия от 18:51, 16 мая 2025
Для документации этого модуля может быть создана страница Модуль:AlchemyRecipe/doc
local p = {}
local darkColors = {
border = "#338833",
bg = "#1a2a1a",
border2 = "#cc7744",
bg2 = "#2a1a12",
border3 = "#2277cc",
bg3 = "#121a26"
}
local function renderIngredients(ingredients)
local parts = {}
for _, item in ipairs(ingredients) do
table.insert(parts, mw.html.create("div"):wikitext(item):allDone())
end
return table.concat(parts, "\n")
end
local function renderEffect(text)
return mw.html.create("div"):addClass("alchemy-effect"):wikitext(text):allDone()
end
local function renderRecipe(text)
return mw.html.create("div"):addClass("alchemy-recipe-block"):wikitext(text):allDone()
end
function p.main(frame)
local args = frame:getParent().args
local ingredients = {}
for k,v in pairs(args) do
if k:match("^ingredient%d*$") then
table.insert(ingredients, v)
end
end
local result = args.result or "?"
local effect = args.effect or ""
local recipe = args.recipe or ""
local html = mw.html.create("div")
:addClass("alchemy-card")
local content = mw.html.create("div")
:addClass("alchemy-content")
:css("display", "flex")
:css("justify-content", "center")
:css("align-items", "center")
-- Левая колонка: ингредиенты вертикально
local left = mw.html.create("div")
:addClass("alchemy-ingredients")
:css("display", "flex")
:css("flex-direction", "column")
:css("gap", "6px")
:css("min-width", "150px")
:wikitext(renderIngredients(ingredients))
-- Центр: слово Смешайте
local center = mw.html.create("div")
:addClass("alchemy-mix")
:css("margin", "0 20px")
:css("font-weight", "bold")
:css("color", darkColors.border)
:wikitext("Смешайте")
-- Правая колонка: результат
local right = mw.html.create("div")
:addClass("alchemy-result")
:css("display", "flex")
:css("flex-direction", "column")
:css("gap", "10px")
right:node(mw.html.create("div"):addClass("alchemy-result-name"):wikitext(result))
if effect ~= "" then
right:node(mw.html.create("div"):addClass("alchemy-effect-block"):wikitext(effect))
end
if recipe ~= "" then
right:node(mw.html.create("div"):addClass("alchemy-recipe-block"):wikitext(recipe))
end
content
:node(left)
:node(center)
:node(right)
html
:node(content)
return tostring(html)
end
return p