forked from VoxeLibre/VoxeLibre
master #5
|
@ -94,4 +94,3 @@ if mcl_weather.reg_weathers.snow == nil then
|
|||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ mcl_weather.state = "none"
|
|||
-- player list for saving player meta info
|
||||
mcl_weather.players = {}
|
||||
|
||||
-- default weather recalculation interval
|
||||
mcl_weather.check_interval = 300
|
||||
-- default weather check interval for global step
|
||||
mcl_weather.check_interval = 5
|
||||
|
||||
-- weather min duration
|
||||
mcl_weather.min_duration = 600
|
||||
|
@ -40,16 +40,16 @@ local storage = minetest.get_mod_storage()
|
|||
local save_weather = function()
|
||||
storage:set_string("mcl_weather_state", mcl_weather.state)
|
||||
storage:set_int("mcl_weather_end_time", mcl_weather.end_time)
|
||||
minetest.log("verbose", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time)
|
||||
minetest.log("action", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time)
|
||||
end
|
||||
minetest.register_on_shutdown(save_weather)
|
||||
|
||||
mcl_weather.get_rand_end_time = function(min_duration, max_duration)
|
||||
local r
|
||||
if min_duration ~= nil and max_duration ~= nil then
|
||||
r = math.random(min_duration, max_duration);
|
||||
r = math.random(min_duration, max_duration)
|
||||
else
|
||||
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration);
|
||||
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration)
|
||||
end
|
||||
return minetest.get_gametime() + r
|
||||
end
|
||||
|
@ -121,7 +121,12 @@ mcl_weather.get_random_pos_by_player_look_dir = function(player)
|
|||
return random_pos_x, random_pos_y, random_pos_z
|
||||
end
|
||||
|
||||
local t, wci = 0, mcl_weather.check_interval
|
||||
minetest.register_globalstep(function(dtime)
|
||||
t = t + dtime
|
||||
if t < wci then return end
|
||||
t = 0
|
||||
|
||||
if mcl_weather.end_time == nil then
|
||||
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
||||
end
|
||||
|
@ -141,7 +146,7 @@ end)
|
|||
|
||||
-- Sets random weather (which could be 'none' (no weather)).
|
||||
mcl_weather.set_random_weather = function(weather_name, weather_meta)
|
||||
if (weather_meta ~= nil) then
|
||||
if weather_meta == nil then return end
|
||||
local transitions = weather_meta.transitions
|
||||
local random_roll = math.random(0,100)
|
||||
local new_weather
|
||||
|
@ -155,7 +160,6 @@ mcl_weather.set_random_weather = function(weather_name, weather_meta)
|
|||
mcl_weather.change_weather(new_weather)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Change weather to new_weather.
|
||||
-- * explicit_end_time is OPTIONAL. If specified, explicitly set the
|
||||
|
|
Loading…
Reference in New Issue