VOOZH about

URL: https://minecraft.wiki/w/Module:Command

⇱ Module:Command – Minecraft Wiki


Module:Command

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

Implements {{Command}}.

[view] [edit] [history] [purge]The above documentation is transcluded from Module:Command/doc.
localp={}
functionp.cmd(f)
localargs=f
iff==mw.getCurrentFrame()then
args=f:getParent().args
end
localcommandName=args[1]:match('^%s*/?([^%s]+)'):lower()
localparams={}
localcommand={}
--getparams
fori,vinipairs(args)do
ifi>1orv:match('^%s*/?(.+)'):lower()~=commandNamethen
table.insert(params,mw.text.trim(v))
end
end
--escape space and split args
if#params==1and(notargs[2]orargs[2]=='...')andparams[1]:find('%s')then
params[1]=params[1]:match('^[^%s]+%s(.+)')
end
command=params
ifargs.linkthen
ifargs.link:lower()~='none'then
commandName='[['..args.link..'|'..commandName..']]'
end
else
commandName='[[Commands/'..commandName..'|'..commandName..']]'
end
table.insert(command,1,commandName)
localslash='/'
ifargs['/']=='0'orargs.slash=='0'then
slash=''
end
localattr=''
ifargs.longthen
attr='style="display: flex; padding: 0.8em 1em; margin-bottom: 0.4em; word-warp: break-word;"'
end
localresult=table.concat(command,' '):gsub('〈space〉',' '):gsub('〈lsqb〉','%['):gsub('〈rsqb〉','%]'):gsub('〈apos〉',"'"):gsub('〈quot〉','"')
-- Don't encode if told not to or if there is a sub-command
ifargs.escape~='0'then
result=result:gsub('<','&lt;'):gsub('&lt;(!%-%- Command %-%->)&lt;','<%1<'):gsub('&lt;/code>&lt;(!%-%- /Command %-%->)','</code><%1')
end
result='<!-- Command --><code '..attr..'><span>'..slash..result..'</span></code><!-- /Command -->'
returnresult
end
returnp
Retrieved from "https://minecraft.wiki/w/Module:Command?oldid=2929056"

Navigation menu