Move chat command handling code from C++ to Lua (#5528)
This commit is contained in:
parent
58e922c884
commit
f12f99333b
|
@ -7,13 +7,22 @@
|
||||||
core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY
|
core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY
|
||||||
|
|
||||||
core.register_on_chat_message(function(name, message)
|
core.register_on_chat_message(function(name, message)
|
||||||
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
|
if message:sub(1,1) ~= "/" then
|
||||||
if not param then
|
return
|
||||||
param = ""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
|
||||||
|
if not cmd then
|
||||||
|
core.chat_send_player(name, "-!- Empty command")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
param = param or ""
|
||||||
|
|
||||||
local cmd_def = core.registered_chatcommands[cmd]
|
local cmd_def = core.registered_chatcommands[cmd]
|
||||||
if not cmd_def then
|
if not cmd_def then
|
||||||
return false
|
core.chat_send_player(name, "-!- Invalid command: " .. cmd)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs)
|
local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs)
|
||||||
if has_privs then
|
if has_privs then
|
||||||
|
|
Loading…
Reference in New Issue