diff options
author | HybridDog <3192173+HybridDog@users.noreply.github.com> | 2020-10-03 18:33:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-03 17:33:43 +0100 |
commit | 4b423ee9b12aabe6ccd6a8e7dbc7db1d89dc365b (patch) | |
tree | 85329034bc72cc9a307047a91ffbd8245d972124 /builtin | |
parent | 947466ab28129fd69e6630974c6c4e901f2bebc6 (diff) | |
download | minetest-4b423ee9b12aabe6ccd6a8e7dbc7db1d89dc365b.tar.gz minetest-4b423ee9b12aabe6ccd6a8e7dbc7db1d89dc365b.tar.bz2 minetest-4b423ee9b12aabe6ccd6a8e7dbc7db1d89dc365b.zip |
Chatcommand: Show help message if func returns false without message
#9440
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/chat.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/builtin/game/chat.lua b/builtin/game/chat.lua index 8131a6860..1d277730a 100644 --- a/builtin/game/chat.lua +++ b/builtin/game/chat.lua @@ -66,8 +66,17 @@ core.register_on_chat_message(function(name, message) local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs) if has_privs then core.set_last_run_mod(cmd_def.mod_origin) - local _, result = cmd_def.func(name, param) - if result then + local success, result = cmd_def.func(name, param) + if success == false and result == nil then + core.chat_send_player(name, "-!- Invalid command usage") + local help_def = core.registered_chatcommands["help"] + if help_def then + local _, helpmsg = help_def.func(name, cmd) + if helpmsg then + core.chat_send_player(name, helpmsg) + end + end + elseif result then core.chat_send_player(name, result) end else |