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 player_names = core.get_player_names()
44 if not player_names then
45 return false, core.gettext("This command is disabled by server.")
48 local players = table.concat(player_names, ", ")
49 return true, core.gettext("Online players: ") .. players
53 core.register_chatcommand("disconnect", {
54 description = core.gettext("Exit to main menu"),
55 func = function(param)
60 core.register_chatcommand("clear_chat_queue", {
61 description = core.gettext("Clear the out chat queue"),
62 func = function(param)
63 core.clear_out_chat_queue()
64 return true, core.gettext("The out chat queue is now empty")
68 function core.run_server_chatcommand(cmd, param)
69 core.send_chat_message("/" .. cmd .. " " .. param)