From 409d04324f0a81eaa78ff9161b4f3593d89151c5 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 11 Jun 2018 13:43:12 +0200 Subject: Fix the /shutdown command (#7431) --- builtin/game/chatcommands.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'builtin/game') 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 -- cgit v1.2.3