From c6a471e5a747091362334ac38a5a0a9445356d7a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 11 Nov 2017 17:18:53 +0100 Subject: [PATCH] =?UTF-8?q?Weather=5Fpack:=20os.time=20=E2=86=92=20minetes?= =?UTF-8?q?t.get=5Fgametime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/ENVIRONMENT/weather_pack/rain.lua | 4 ++-- mods/ENVIRONMENT/weather_pack/thunder.lua | 6 +++--- mods/ENVIRONMENT/weather_pack/weather_core.lua | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mods/ENVIRONMENT/weather_pack/rain.lua b/mods/ENVIRONMENT/weather_pack/rain.lua index 60b6acfc32..81b3494ab0 100644 --- a/mods/ENVIRONMENT/weather_pack/rain.lua +++ b/mods/ENVIRONMENT/weather_pack/rain.lua @@ -104,7 +104,7 @@ end rain.update_sound = function(player) local player_meta = weather.players[player:get_player_name()] if player_meta ~= nil then - if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > os.time() then + if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then return false end @@ -117,7 +117,7 @@ rain.update_sound = function(player) player_meta.sound_handler = rain.sound_handler(player) end - player_meta.sound_updated = os.time() + player_meta.sound_updated = minetest.get_gametime() end end diff --git a/mods/ENVIRONMENT/weather_pack/thunder.lua b/mods/ENVIRONMENT/weather_pack/thunder.lua index 3ff6453916..1cd61fa3fe 100644 --- a/mods/ENVIRONMENT/weather_pack/thunder.lua +++ b/mods/ENVIRONMENT/weather_pack/thunder.lua @@ -14,10 +14,10 @@ minetest.register_globalstep(function(dtime) rain.make_weather() - if (thunder.next_strike <= os.time()) then + if (thunder.next_strike <= minetest.get_gametime()) then lightning.strike() local delay = math.random(thunder.min_delay, thunder.max_delay) - thunder.next_strike = os.time() + delay + thunder.next_strike = minetest.get_gametime() + delay end end) @@ -34,4 +34,4 @@ if weather.reg_weathers.thunder == nil then min_duration = 120, max_duration = 600, } -end \ No newline at end of file +end diff --git a/mods/ENVIRONMENT/weather_pack/weather_core.lua b/mods/ENVIRONMENT/weather_pack/weather_core.lua index 912cf1c03d..d722231721 100644 --- a/mods/ENVIRONMENT/weather_pack/weather_core.lua +++ b/mods/ENVIRONMENT/weather_pack/weather_core.lua @@ -32,9 +32,9 @@ weather = { weather.get_rand_end_time = function(min_duration, max_duration) if min_duration ~= nil and max_duration ~= nil then - return os.time() + math.random(min_duration, max_duration); + return minetest.get_gametime() + math.random(min_duration, max_duration); else - return os.time() + math.random(weather.min_duration, weather.max_duration); + return minetest.get_gametime() + math.random(weather.min_duration, weather.max_duration); end end @@ -99,29 +99,29 @@ minetest.register_globalstep(function(dtime) -- recalculate weather only when there aren't currently any if (weather.state ~= "none") then - if (weather.end_time ~= nil and weather.end_time <= os.time()) then + if (weather.end_time ~= nil and weather.end_time <= minetest.get_gametime()) then weather.reg_weathers[weather.state].clear() weather.state = "none" end - elseif (weather.next_check <= os.time()) then + elseif (weather.next_check <= minetest.get_gametime()) then for weather_name, weather_meta in pairs(weather.reg_weathers) do weather.set_random_weather(weather_name, weather_meta) end -- fallback next_check set, weather 'none' will be. - weather.next_check = os.time() + weather.check_interval + weather.next_check = minetest.get_gametime() + weather.check_interval end end) -- sets random weather (which could be 'regular' (no weather)). weather.set_random_weather = function(weather_name, weather_meta) - if weather.next_check > os.time() then return 0 end + if weather.next_check > minetest.get_gametime() then return 0 end if (weather_meta ~= nil and weather_meta.chance ~= nil) then local random_roll = math.random(0,100) if (random_roll <= weather_meta.chance) then weather.state = weather_name weather.end_time = weather.get_rand_end_time(weather_meta.min_duration, weather_meta.max_duration) - weather.next_check = os.time() + weather.check_interval + weather.next_check = minetest.get_gametime() + weather.check_interval end end end