Show all available chatcommands when the desired one was not found

This commit is contained in:
HybridDog 2018-07-18 18:56:59 +02:00
parent 1129cb1601
commit e53175df55

@ -18,7 +18,14 @@ local command_invoker
local function override_chatcommand(cname, func_before, func_after)
local command = minetest.registered_chatcommands[cname]
assert(command, "Chatcommand " .. cname .. " isn't registered.")
if not command then
local cmds = {}
for name in pairs(minetest.registered_chatcommands) do
cmds[#cmds+1] = name
end
error("Chatcommand " .. cname .. " is not registered.\n" ..
"Available commands: " .. table.concat(cmds, ", "))
end
-- save the name of the player and execute func_before if present
if func_before then
local func = command.func