@@ -93,6 +93,56 @@ minetest.register_chatcommand("/about", {
9393 end ,
9494})
9595
96+ -- mostly copied from builtin/chatcommands.lua with minor modifications
97+ minetest .register_chatcommand (" /help" , {
98+ privs = {},
99+ params = " [all/<cmd>]" ,
100+ description = " Get help for WorldEdit commands" ,
101+ func = function (name , param )
102+ local function is_we_command (cmd )
103+ return cmd :sub (0 , 1 ) == " /"
104+ end
105+ local function format_help_line (cmd , def )
106+ local msg = minetest .colorize (" #00ffff" , " /" .. cmd )
107+ if def .params and def .params ~= " " then
108+ msg = msg .. " " .. def .params
109+ end
110+ if def .description and def .description ~= " " then
111+ msg = msg .. " : " .. def .description
112+ end
113+ return msg
114+ end
115+
116+ if not minetest .check_player_privs (name , " worldedit" ) then
117+ return false , " You are not allowed to use any WorldEdit commands."
118+ end
119+ if param == " " then
120+ local msg = " "
121+ local cmds = {}
122+ for cmd , def in pairs (minetest .chatcommands ) do
123+ if is_we_command (cmd ) and minetest .check_player_privs (name , def .privs ) then
124+ cmds [# cmds + 1 ] = cmd :sub (2 ) -- strip the /
125+ end
126+ end
127+ table.sort (cmds )
128+ return true , " Available commands: " .. table.concat (cmds , " " ) .. " \n "
129+ .. " Use '//help <cmd>' to get more information,"
130+ .. " or '//help all' to list everything."
131+ elseif param == " all" then
132+ local cmds = {}
133+ for cmd , def in pairs (minetest .chatcommands ) do
134+ if is_we_command (cmd ) and minetest .check_player_privs (name , def .privs ) then
135+ cmds [# cmds + 1 ] = format_help_line (cmd , def )
136+ end
137+ end
138+ table.sort (cmds )
139+ return true , " Available commands:\n " .. table.concat (cmds , " \n " )
140+ else
141+ return minetest .chatcommands [" help" ].func (name , " /" .. param )
142+ end
143+ end ,
144+ })
145+
96146minetest .register_chatcommand (" /inspect" , {
97147 params = " on/off/1/0/true/false/yes/no/enable/disable/<blank>" ,
98148 description = " Enable or disable node inspection" ,
0 commit comments