diff options
author | red-001 <red-001@outlook.ie> | 2017-04-08 19:03:57 +0100 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-04-08 20:03:57 +0200 |
commit | d4e9dd4643607192f5adebeecda86f25074f02cd (patch) | |
tree | 14683abebf623f29a7d198d9feb94b800fd84947 /builtin | |
parent | fb4c730708a4140f05d2161c27e6c58bb0f72a9b (diff) | |
download | minetest-d4e9dd4643607192f5adebeecda86f25074f02cd.tar.gz minetest-d4e9dd4643607192f5adebeecda86f25074f02cd.tar.bz2 minetest-d4e9dd4643607192f5adebeecda86f25074f02cd.zip |
Move chat command handling code from C++ to Lua (#5528)
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/chatcommands.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 16f5f3be9..8df3903d2 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -7,13 +7,22 @@ core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY core.register_on_chat_message(function(name, message) + if message:sub(1,1) ~= "/" then + return + end + local cmd, param = string.match(message, "^/([^ ]+) *(.*)") - if not param then - param = "" + if not cmd then + core.chat_send_player(name, "-!- Empty command") + return true end + + param = param or "" + local cmd_def = core.registered_chatcommands[cmd] if not cmd_def then - return false + core.chat_send_player(name, "-!- Invalid command: " .. cmd) + return true end local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs) if has_privs then |