Модуль:Только для

Модуль реализует шаблон {{Только для}} посредством сборки шаблона {{Ambox}}.

local p = {} -- Приведение названий изданий к нормализованным local edition_names = { ["компьютер"] = "java", ["пк"] = "java", ["java"] = "java", ["Java"] = "java", ["pocket"] = "bedrock", ["Pocket"] = "bedrock", ["bedrock"] = "bedrock", ["Bedrock"] = "bedrock", ["console"] = "console", ["Console"] = "console", ["legacy console"] = "console", ["Legacy console"] = "console", ["PlayStation 4"] = "ps4", ["ps4"] = "ps4", ["education"] = "education", ["Education"] = "education", ["new3ds"] = "3ds", ["New3ds"] = "3ds", ["nintendo"] = "3ds", ["Nintendo"] = "3ds", ["new nintendo 3ds"] = "3ds", ["New Nintendo 3DS"] = "3ds", ["earth"] = "minecraft earth", ["Minecraft earth"] = "minecraft earth", ["Minecraft Earth"] = "minecraft earth", ["Earth"] = "minecraft earth", } -- Данные об изданиях local editions = { ["java"] = {link = "Java Edition", title = "Java Edition", category = "Java Edition"}, ["bedrock"] = {link = "Bedrock Edition", title = "Bedrock Edition", category = "Bedrock Edition"}, ["console"] = {link = "Legacy Console Edition", title = "Legacy Console Edition", category = "Legacy Console Edition"}, ["ps4"] = {link = "PlayStation 4 Edition", title = "PlayStation 4 Edition", category = "PlayStation 4 Edition"}, ["education"] = {link = "Education Edition", title = "Education Edition", category = "Education Edition"}, ["3ds"] = {link = "New Nintendo 3DS Edition", title = "New Nintendo 3DS Edition", category = "New Nintendo 3DS Edition"}, ["minecraft earth"] = {link = "Minecraft Earth", title = "Minecraft Earth", category = "Minecraft Earth"} } function p.only(f) local args = f.args or f if f == mw.getCurrentFrame() and args[1] == nil then args = f:getParent().args end local params = {} local edition_text = {} local categories = {} local lang = mw.language.getContentLanguage() for i, v in ipairs(args) do local edition_name = mw.text.trim(v) if edition_names[edition_name] then local edition = editions[edition_names[edition_name]] table.insert(edition_text, ("[[%s|%s]]"):format(edition.link, edition.title)) table.insert(categories, ("[[Категория:%s]]"):format(edition.category)) else local link = lang:ucfirst(edition_name) .. " Edition" table.insert(edition_text, ("[[%s]]"):format(link)) table.insert(categories, ("[[Категория:%s]]"):format(edition_name)) end end local text = "'''Только для " local n_editions = #edition_text for i, link in ipairs(edition_text) do if i > 1 then if i == n_editions then text = text .. " и " else text = text .. ", " end end text = text .. link end text = text .. "'''" params["border"] = "blue" params["image"] = "[[Файл:Information icon.svg|24px]]" params["text"] = text local result = mw.getCurrentFrame():expandTemplate({title = "Ambox", args = params}) if not args["некат"] then local title = mw.title.getCurrentTitle() -- namespace 2 — «Участник» if title.namespace ~= 2 and not title.isTalkPage then result = result .. table.concat(categories) end end return result end return p 
В данной статье используются материалы из статьи «Модуль:Только для» с вики-сайта Minecraft Wiki, расположенного на Фэндоме, и они распространяются согласно лицензии Creative Commons Attribution-NonCommercial-ShareAlike 3.0. Авторы статьи.