end,\r
})\r
\r
+-- mostly copied from builtin/chatcommands.lua with minor modifications\r
+minetest.register_chatcommand("/help", {\r
+ privs = {},\r
+ params = "[all/<cmd>]",\r
+ description = "Get help for WorldEdit commands",\r
+ func = function(name, param)\r
+ local function is_we_command(cmd)\r
+ return cmd:sub(0, 1) == "/"\r
+ end\r
+ local function format_help_line(cmd, def)\r
+ local msg = minetest.colorize("#00ffff", "/"..cmd)\r
+ if def.params and def.params ~= "" then\r
+ msg = msg .. " " .. def.params\r
+ end\r
+ if def.description and def.description ~= "" then\r
+ msg = msg .. ": " .. def.description\r
+ end\r
+ return msg\r
+ end\r
+\r
+ if not minetest.check_player_privs(name, "worldedit") then\r
+ return false, "You are not allowed to use any WorldEdit commands."\r
+ end\r
+ if param == "" then\r
+ local msg = ""\r
+ local cmds = {}\r
+ for cmd, def in pairs(minetest.chatcommands) do\r
+ if is_we_command(cmd) and minetest.check_player_privs(name, def.privs) then\r
+ cmds[#cmds + 1] = cmd:sub(2) -- strip the /\r
+ end\r
+ end\r
+ table.sort(cmds)\r
+ return true, "Available commands: " .. table.concat(cmds, " ") .. "\n"\r
+ .. "Use '//help <cmd>' to get more information,"\r
+ .. " or '//help all' to list everything."\r
+ elseif param == "all" then\r
+ local cmds = {}\r
+ for cmd, def in pairs(minetest.chatcommands) do\r
+ if is_we_command(cmd) and minetest.check_player_privs(name, def.privs) then\r
+ cmds[#cmds + 1] = format_help_line(cmd, def)\r
+ end\r
+ end\r
+ table.sort(cmds)\r
+ return true, "Available commands:\n"..table.concat(cmds, "\n")\r
+ else\r
+ return minetest.chatcommands["help"].func(name, "/" .. param)\r
+ end\r
+ end,\r
+})\r
+\r
minetest.register_chatcommand("/inspect", {\r
params = "on/off/1/0/true/false/yes/no/enable/disable/<blank>",\r
description = "Enable or disable node inspection",\r