diff options
Diffstat (limited to 'builtin/game')
-rw-r--r-- | builtin/game/chatcommands.lua | 16 | ||||
-rw-r--r-- | builtin/game/misc.lua | 5 |
2 files changed, 16 insertions, 5 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 8df3903d2..25cc06178 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -763,14 +763,20 @@ core.register_chatcommand("days", { core.register_chatcommand("shutdown", { description = "Shutdown server", - params = "[reconnect] [message]", + params = "[delay_in_seconds(0..inf) or -1 for cancel] [reconnect] [message]", privs = {server=true}, func = function(name, param) - core.log("action", name .. " shuts down server") - core.chat_send_all("*** Server shutting down (operator request).") - local reconnect, message = param:match("([^ ]+)(.*)") + local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)") message = message or "" - core.request_shutdown(message:trim(), core.is_yes(reconnect)) + + if delay ~= "" then + delay = tonumber(param) or 0 + else + delay = 0 + core.log("action", name .. " shuts down server") + core.chat_send_all("*** Server shutting down (operator request).") + end + core.request_shutdown(message:trim(), core.is_yes(reconnect), delay) end, }) diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 618d4d97f..a3eb26ac2 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -173,3 +173,8 @@ end function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end + +function core.cancel_shutdown_requests() + core.request_shutdown("", false, -1) +end + |