Weather_pack: os.time → minetest.get_gametime
This commit is contained in:
parent
53f231a576
commit
c6a471e5a7
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue