summaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-06-11 13:43:12 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-06-11 13:43:12 +0200
commit409d04324f0a81eaa78ff9161b4f3593d89151c5 (patch)
treecdd5f688a639ce3eb34dde450173989907e52c94 /builtin/game
parentfb4e4f048ea8c53d20465ee17fddbfc0ae946b74 (diff)
downloadminetest-409d04324f0a81eaa78ff9161b4f3593d89151c5.tar.gz
minetest-409d04324f0a81eaa78ff9161b4f3593d89151c5.tar.bz2
minetest-409d04324f0a81eaa78ff9161b4f3593d89151c5.zip
Fix the /shutdown command (#7431)
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/chatcommands.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 3b701c1fd..31ce4359f 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -827,13 +827,15 @@ core.register_chatcommand("shutdown", {
description = "Shutdown server (-1 cancels a delayed shutdown)",
privs = {server=true},
func = function(name, param)
- local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
- message = message or ""
+ local delay, reconnect, message
+ delay, param = param:match("^%s*(%S+)(.*)")
+ if param then
+ reconnect, param = param:match("^%s*(%S+)(.*)")
+ end
+ message = param and param:match("^%s*(.+)") or ""
+ delay = tonumber(delay) or 0
- if delay ~= "" then
- delay = tonumber(delay) or 0
- else
- delay = 0
+ if delay == 0 then
core.log("action", name .. " shuts down server")
core.chat_send_all("*** Server shutting down (operator request).")
end