1 -- Minetest: builtin/client/chatcommands.lua
4 core.register_on_sending_chat_message(function(message)
5 if message:sub(1,2) == ".." then
9 local first_char = message:sub(1,1)
10 if first_char == "/" or first_char == "." then
11 core.display_chat_message(core.gettext("issued command: ") .. message)
14 if first_char ~= "." then
18 local cmd, param = string.match(message, "^%.([^ ]+) *(.*)")
22 core.display_chat_message(core.gettext("-!- Empty command"))
26 local cmd_def = core.registered_chatcommands[cmd]
28 core.set_last_run_mod(cmd_def.mod_origin)
29 local _, message = cmd_def.func(param)
31 core.display_chat_message(message)
34 core.display_chat_message(core.gettext("-!- Invalid command: ") .. cmd)
40 core.register_chatcommand("list_players", {
41 description = core.gettext("List online players"),
42 func = function(param)
43 local players = table.concat(core.get_player_names(), ", ")
44 core.display_chat_message(core.gettext("Online players: ") .. players)
48 core.register_chatcommand("disconnect", {
49 description = core.gettext("Exit to main menu"),
50 func = function(param)
55 core.register_chatcommand("clear_chat_queue", {
56 description = core.gettext("Clear the out chat queue"),
57 func = function(param)
58 core.clear_out_chat_queue()
59 return true, core.gettext("The out chat queue is now empty")
63 function core.run_server_chatcommand(cmd, param)
64 core.send_chat_message("/" .. cmd .. " " .. param)