diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 68fb169f0..301a8050c 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -7,6 +7,7 @@ dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "mod_storage.lua") dofile(commonpath .. "chatcommands.lua") +dofile(commonpath .. "information_formspecs.lua") dofile(clientpath .. "chatcommands.lua") dofile(clientpath .. "death_formspec.lua") dofile(clientpath .. "misc.lua") diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index 7c3da0601..7a8a49558 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -89,7 +89,7 @@ local function do_help_cmd(name, param) if #args > 1 then return false, S("Too many arguments, try using just /help ") end - local use_gui = INIT ~= "client" and core.get_player_by_name(name) + local use_gui = INIT == "client" or core.get_player_by_name(name) use_gui = use_gui and not opts:find("t") if #args == 0 and not use_gui then @@ -163,8 +163,8 @@ end if INIT == "client" then core.register_chatcommand("help", { - params = core.gettext("[all | ]"), - description = core.gettext("Get help for commands"), + params = core.gettext("[all | ] [-t]"), + description = core.gettext("Get help for commands (-t: output in chat)"), func = function(param) return do_help_cmd(nil, param) end, diff --git a/builtin/common/information_formspecs.lua b/builtin/common/information_formspecs.lua index 3405263bf..3fa397d25 100644 --- a/builtin/common/information_formspecs.lua +++ b/builtin/common/information_formspecs.lua @@ -61,15 +61,20 @@ local function build_chatcommands_formspec(name, sel, copy) for i, data in ipairs(mod_cmds) do rows[#rows + 1] = COLOR_BLUE .. ",0," .. F(data[1]) .. "," for j, cmds in ipairs(data[2]) do - local has_priv = check_player_privs(name, cmds[2].privs) + local has_priv = INIT == "client" or check_player_privs(name, cmds[2].privs) rows[#rows + 1] = ("%s,1,%s,%s"):format( has_priv and COLOR_GREEN or COLOR_GRAY, cmds[1], F(cmds[2].params)) if sel == #rows then description = cmds[2].description if copy then - core.chat_send_player(name, S("Command: @1 @2", - core.colorize("#0FF", "/" .. cmds[1]), cmds[2].params)) + local msg = S("Command: @1 @2", + core.colorize("#0FF", "/" .. cmds[1]), cmds[2].params) + if INIT == "client" then + core.display_chat_message(msg) + else + core.chat_send_player(name, msg) + end end end end @@ -111,26 +116,46 @@ end -- DETAILED CHAT COMMAND INFORMATION +if INIT == "client" then + core.register_on_formspec_input(function(formname, fields) + if formname ~= "__builtin:help_cmds" or fields.quit then + return + end -core.register_on_player_receive_fields(function(player, formname, fields) - if formname ~= "__builtin:help_cmds" or fields.quit then - return - end + local event = core.explode_table_event(fields.list) + if event.type ~= "INV" then + core.show_formspec("__builtin:help_cmds", + build_chatcommands_formspec(nil, event.row, event.type == "DCL")) + end + end) +else + core.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "__builtin:help_cmds" or fields.quit then + return + end - local event = core.explode_table_event(fields.list) - if event.type ~= "INV" then - local name = player:get_player_name() - core.show_formspec(name, "__builtin:help_cmds", - build_chatcommands_formspec(name, event.row, event.type == "DCL")) - end -end) + local event = core.explode_table_event(fields.list) + if event.type ~= "INV" then + local name = player:get_player_name() + core.show_formspec(name, "__builtin:help_cmds", + build_chatcommands_formspec(name, event.row, event.type == "DCL")) + end + end) +end function core.show_general_help_formspec(name) - core.show_formspec(name, "__builtin:help_cmds", - build_chatcommands_formspec(name)) + if INIT == "client" then + core.show_formspec("__builtin:help_cmds", + build_chatcommands_formspec(name)) + else + core.show_formspec(name, "__builtin:help_cmds", + build_chatcommands_formspec(name)) + end end -function core.show_privs_help_formspec(name) - core.show_formspec(name, "__builtin:help_privs", - build_privs_formspec(name)) +if INIT ~= "client" then + function core.show_privs_help_formspec(name) + core.show_formspec(name, "__builtin:help_privs", + build_privs_formspec(name)) + end end