diff options
author | red-001 <red-001@outlook.ie> | 2017-03-24 23:43:36 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-03-26 05:51:14 +0100 |
commit | e70e15134c95d37241bb6f6124105c0f1c08ab8a (patch) | |
tree | 6cafdf536c8c77e350abe7a249fa91c695c9165e /builtin/client | |
parent | 4d5177ff708c7e696eead18200e240047ff520fe (diff) | |
download | minetest-e70e15134c95d37241bb6f6124105c0f1c08ab8a.tar.gz minetest-e70e15134c95d37241bb6f6124105c0f1c08ab8a.tar.bz2 minetest-e70e15134c95d37241bb6f6124105c0f1c08ab8a.zip |
Change command prefix to "." and add "help" command.
Diffstat (limited to 'builtin/client')
-rw-r--r-- | builtin/client/chatcommands.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 43b4d9a72..7a1b4b6b7 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -2,27 +2,35 @@ core.register_on_sending_chat_messages(function(message) - if not (message:sub(1,1) == "/") then - return false + local first_char = message:sub(1,1) + if first_char == "/" or first_char == "." then + core.display_chat_message("issued command: " .. message) end - core.display_chat_message("issued command: " .. message) + if first_char ~= "." then + return false + end - local cmd, param = string.match(message, "^/([^ ]+) *(.*)") + local cmd, param = string.match(message, "^%.([^ ]+) *(.*)") if not param then param = "" end - local cmd_def = core.registered_chatcommands[cmd] + if not cmd then + core.display_chat_message("-!- Empty command") + return true + end + local cmd_def = core.registered_chatcommands[cmd] if cmd_def then core.set_last_run_mod(cmd_def.mod_origin) local _, message = cmd_def.func(param) if message then core.display_chat_message(message) end - return true + else + core.display_chat_message("-!- Invalid command: " .. cmd) end - return false + return true end) |