From 5faec7598fd1d493467ccdd79086b7360c559606 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Mon, 16 May 2016 14:14:48 +0200 Subject: [PATCH] Set time_speed to normal value on shutdown - For #4 --- init.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index b783f05..b69482b 100644 --- a/init.lua +++ b/init.lua @@ -3,12 +3,12 @@ -- By Mg/LeMagnesium -- License: WTFPL -- Last modification : --- 05/12/16 @ 12:20PM GMT+1 (Mg) +-- 05/16/16 @ 02:14PM GMT+1 (Mg) -- -- Namespace first, with basic informations time_reg = {} -time_reg.version = "00.01.24" +time_reg.version = "00.01.25" time_reg.authors = {"Mg/LeMagnesium"} -- Definitions @@ -367,6 +367,15 @@ function time_reg.init() time_reg.log("\tNight: " .. 1440 / time_reg.night_time_speed .. " minutes") end +-- Shutdown +-- Sometimes MT will shutdown and write current time_speed in minetest.conf; we need to change the value back to normal before it happens +function time_reg.on_shutdown() + minetest.setting_set("time_speed", time_reg.time_speed) + time_reg.log("Time speed set back to " .. time_reg.time_speed) +end + +minetest.register_on_shutdown(time_reg.on_shutdown) + -- --[[ NOW WE SHALL START ]]-- -- time_reg.log("Thank you for using TimeRegulation v" .. time_reg.version .. " by " .. table.concat(time_reg.authors, ", "))