Module
BannerFromCommand
From Dogcraft Wiki
Documentation for this module may be created at Module:BannerFromCommand/doc
-- Copyright (c) 2024, XPModder, Dogcraft.net and contributors
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--
-- End license text.
-- A module to parse minecraft give commands for banners
local p = {}
-- The main function called on #invoke via the template
function p.Parse(frame)
local args = {}
-- get the arguments
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
else
args = frame.args
end
local command = tostring(args.command)
if command == nil or command == "nil" then
return "Error! No command given!"
end
local bannerstart, bannerstop, bannercolor = string.find(command, "%s*(%S*)_banner%s*%[")
local nbt = string.sub(command, bannerstop)
local iterator = string.gmatch(nbt, "{(.*)}%s*,")
local res = "{{Banner|color=" .. bannercolor
for i = 1, 16 do
local part = iterator()
if part == nil then
break
end
local patternstart, patternstop, pattern = string.find(part, "pattern:%s*([^%s,]*)")
local guipattern = frame:expandTemplate{name="BannerPatternTranslate", args={pattern}}
local colorstart, colorstop, color = string.find(part, "color:%s*([^%s,]*)")
res = res .. "|pattern" .. i .. "=" .. guipattern .. "|patternColor" .. i .. "=" .. color
end
res = res .. "}}"
return res
end
return p
This page was last modified on 10 February 2026, at 16:29. (2 days ago)