master #5

Merged
epCode merged 255 commits from VoxeLibre/VoxeLibre:master into master 2021-02-02 23:20:01 +01:00
2 changed files with 176 additions and 173 deletions
Showing only changes of commit 1f18c2438c - Show all commits

View File

@ -94,4 +94,3 @@ if mcl_weather.reg_weathers.snow == nil then
}
}
end

View File

@ -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