From e53175df55b112e518097f0fa9359f6c23e37e4d Mon Sep 17 00:00:00 2001 From: HybridDog Date: Wed, 18 Jul 2018 18:56:59 +0200 Subject: [PATCH] Show all available chatcommands when the desired one was not found --- init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 6b4fad9..854bc35 100644 --- a/init.lua +++ b/init.lua @@ -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