2017-01-22 09:05:09 +01:00
|
|
|
-- Minetest: builtin/client/chatcommands.lua
|
|
|
|
|
|
|
|
|
|
|
|
core.register_on_sending_chat_messages(function(message)
|
|
|
|
if not (message:sub(1,1) == "/") then
|
|
|
|
return false
|
|
|
|
end
|
2017-01-27 07:41:10 +01:00
|
|
|
|
2017-01-22 09:05:09 +01:00
|
|
|
core.display_chat_message("issued command: " .. message)
|
2017-01-27 07:41:10 +01:00
|
|
|
|
2017-01-22 09:05:09 +01:00
|
|
|
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
|
|
|
|
if not param then
|
|
|
|
param = ""
|
|
|
|
end
|
2017-01-27 07:41:10 +01:00
|
|
|
|
2017-01-22 09:05:09 +01:00
|
|
|
local cmd_def = core.registered_chatcommands[cmd]
|
2017-01-27 07:41:10 +01:00
|
|
|
|
2017-01-22 09:05:09 +01:00
|
|
|
if cmd_def then
|
|
|
|
core.set_last_run_mod(cmd_def.mod_origin)
|
2017-01-27 07:41:10 +01:00
|
|
|
local _, message = cmd_def.func(param)
|
2017-01-22 09:05:09 +01:00
|
|
|
if message then
|
|
|
|
core.display_chat_message(message)
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
2017-01-27 07:41:10 +01:00
|
|
|
|
2017-01-22 09:05:09 +01:00
|
|
|
return false
|
2017-01-27 07:41:10 +01:00
|
|
|
end)
|