]> git.lizzy.rs Git - minetest.git/commitdiff
Also print help commands to chat for server terminal (#8869)
authorTim Myers <temyers240@gmail.com>
Wed, 18 Sep 2019 22:37:56 +0000 (17:37 -0500)
committersfan5 <sfan5@live.de>
Wed, 18 Sep 2019 22:37:56 +0000 (00:37 +0200)
builtin/common/chatcommands.lua
builtin/common/information_formspecs.lua

index 71204657c976e09535f1417caed0c0c7ebea8296..52edda659baab0a89ede36a09b6c45faf6877641 100644 (file)
@@ -77,6 +77,13 @@ local function do_help_cmd(name, param)
                end
                table.sort(cmds)
                return true, gettext("Available commands:").."\n"..table.concat(cmds, "\n")
+       elseif INIT == "game" and param == "privs" then
+               local privs = {}
+               for priv, def in pairs(core.registered_privileges) do
+                       privs[#privs + 1] = priv .. ": " .. def.description
+               end
+               table.sort(privs)
+               return true, "Available privileges:\n"..table.concat(privs, "\n")
        else
                local cmd = param
                local def = core.registered_chatcommands[cmd]
index 10fe37b8f4cfccd19792ae1cfbb9df187f6e6e13..b977e2656947a40c9757f2fc0d3072230969a45b 100644 (file)
@@ -81,7 +81,7 @@ local function build_chatcommands_formspec(name, sel, copy)
 end
 
 
---     PRIVILEGES FORMSPEC
+-- PRIVILEGES FORMSPEC
 
 local function build_privs_formspec(name)
        local privs = {}
@@ -128,15 +128,23 @@ local help_command = core.registered_chatcommands["help"]
 local old_help_func = help_command.func
 
 help_command.func = function(name, param)
+       local admin = core.settings:get("name")
+
+       -- If the admin ran help, put the output in the chat buffer as well to
+       -- work with the server terminal
        if param == "privs" then
                core.show_formspec(name, "__builtin:help_privs",
                        build_privs_formspec(name))
-               return
+               if name ~= admin then
+                       return
+               end
        end
        if param == "" or param == "all" then
                core.show_formspec(name, "__builtin:help_cmds",
                        build_chatcommands_formspec(name))
-               return
+               if name ~= admin then
+                       return
+               end
        end
 
        return old_help_func(name, param)