1 -- Minetest: builtin/client/chatcommands.lua
4 core.register_on_sending_chat_messages(function(message)
5 local first_char = message:sub(1,1)
6 if first_char == "/" or first_char == "." then
7 core.display_chat_message("issued command: " .. message)
10 if first_char ~= "." then
14 local cmd, param = string.match(message, "^%.([^ ]+) *(.*)")
20 core.display_chat_message("-!- Empty command")
24 local cmd_def = core.registered_chatcommands[cmd]
26 core.set_last_run_mod(cmd_def.mod_origin)
27 local _, message = cmd_def.func(param)
29 core.display_chat_message(message)
32 core.display_chat_message("-!- Invalid command: " .. cmd)
38 core.register_chatcommand("list_players", {
39 description = "List online players",
40 func = function(param)
41 local players = table.concat(core.get_player_names(), ", ")
42 core.display_chat_message("Online players: " .. players)
46 core.register_chatcommand("disconnect", {
47 description = "Exit to main menu",
48 func = function(param)