mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-24 14:25:10 +00:00
Weather_pack: os.time → minetest.get_gametime
This commit is contained in:
parent
53f231a576
commit
c6a471e5a7
3 changed files with 12 additions and 12 deletions
|
@ -104,7 +104,7 @@ end
|
||||||
rain.update_sound = function(player)
|
rain.update_sound = function(player)
|
||||||
local player_meta = weather.players[player:get_player_name()]
|
local player_meta = weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil then
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ rain.update_sound = function(player)
|
||||||
player_meta.sound_handler = rain.sound_handler(player)
|
player_meta.sound_handler = rain.sound_handler(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
player_meta.sound_updated = os.time()
|
player_meta.sound_updated = minetest.get_gametime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
rain.make_weather()
|
rain.make_weather()
|
||||||
|
|
||||||
if (thunder.next_strike <= os.time()) then
|
if (thunder.next_strike <= minetest.get_gametime()) then
|
||||||
lightning.strike()
|
lightning.strike()
|
||||||
local delay = math.random(thunder.min_delay, thunder.max_delay)
|
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
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -32,9 +32,9 @@ weather = {
|
||||||
|
|
||||||
weather.get_rand_end_time = function(min_duration, max_duration)
|
weather.get_rand_end_time = function(min_duration, max_duration)
|
||||||
if min_duration ~= nil and max_duration ~= nil then
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,29 +99,29 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
-- recalculate weather only when there aren't currently any
|
-- recalculate weather only when there aren't currently any
|
||||||
if (weather.state ~= "none") then
|
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.reg_weathers[weather.state].clear()
|
||||||
weather.state = "none"
|
weather.state = "none"
|
||||||
end
|
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
|
for weather_name, weather_meta in pairs(weather.reg_weathers) do
|
||||||
weather.set_random_weather(weather_name, weather_meta)
|
weather.set_random_weather(weather_name, weather_meta)
|
||||||
end
|
end
|
||||||
-- fallback next_check set, weather 'none' will be.
|
-- 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
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- sets random weather (which could be 'regular' (no weather)).
|
-- sets random weather (which could be 'regular' (no weather)).
|
||||||
weather.set_random_weather = function(weather_name, weather_meta)
|
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
|
if (weather_meta ~= nil and weather_meta.chance ~= nil) then
|
||||||
local random_roll = math.random(0,100)
|
local random_roll = math.random(0,100)
|
||||||
if (random_roll <= weather_meta.chance) then
|
if (random_roll <= weather_meta.chance) then
|
||||||
weather.state = weather_name
|
weather.state = weather_name
|
||||||
weather.end_time = weather.get_rand_end_time(weather_meta.min_duration, weather_meta.max_duration)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue