mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-01 23:11:11 +01:00
Fix more weather length issues
This commit is contained in:
parent
de6096f47a
commit
b220a07877
1 changed files with 7 additions and 5 deletions
|
@ -6,7 +6,7 @@ weather = {
|
||||||
players = {},
|
players = {},
|
||||||
|
|
||||||
-- time when weather should be re-calculated
|
-- time when weather should be re-calculated
|
||||||
next_check = 0,
|
next_check = nil,
|
||||||
|
|
||||||
-- default weather recalculation interval
|
-- default weather recalculation interval
|
||||||
check_interval = 150,
|
check_interval = 150,
|
||||||
|
@ -102,6 +102,12 @@ minetest.register_globalstep(function(dtime)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if weather.end_time == nil then
|
||||||
|
weather.end_time = weather.get_rand_end_time()
|
||||||
|
end
|
||||||
|
if weather.next_check == nil then
|
||||||
|
weather.next_check = minetest.get_gametime() + weather.check_interval
|
||||||
|
end
|
||||||
-- 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 <= minetest.get_gametime()) then
|
if (weather.end_time ~= nil and weather.end_time <= minetest.get_gametime()) then
|
||||||
|
@ -112,15 +118,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
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.
|
|
||||||
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 > 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
|
||||||
|
|
Loading…
Reference in a new issue