1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Change command prefix to "." and add "help" command.

This commit is contained in:
red-001 2017-03-24 23:43:36 +00:00 committed by paramat
parent 4d5177ff70
commit e70e15134c
9 changed files with 103 additions and 63 deletions

View file

@ -2,27 +2,35 @@
core.register_on_sending_chat_messages(function(message)
if not (message:sub(1,1) == "/") then
local first_char = message:sub(1,1)
if first_char == "/" or first_char == "." then
core.display_chat_message("issued command: " .. message)
end
if first_char ~= "." then
return false
end
core.display_chat_message("issued command: " .. message)
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)