forked from Mirrorlandia_minetest/minetest
Chatcommand: Show help message if func returns false without message
#9440
This commit is contained in:
parent
947466ab28
commit
4b423ee9b1
@ -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
|
||||
|
@ -7949,6 +7949,8 @@ Used by `minetest.register_chatcommand`.
|
||||
|
||||
func = function(name, param),
|
||||
-- Called when command is run. Returns boolean success and text output.
|
||||
-- Special case: The help message is shown to the player if `func`
|
||||
-- returns false without a text output.
|
||||
}
|
||||
|
||||
Note that in params, use of symbols is as follows:
|
||||
|
Loading…
Reference in New Issue
Block a user