forked from VoxeLibre/VoxeLibre
Fixed Sleeping Times based on time and storm status
This commit is contained in:
parent
f4ac6335eb
commit
847e37c81f
|
@ -251,16 +251,30 @@ end
|
||||||
|
|
||||||
-- Handle environment stuff related to sleeping: skip night and thunderstorm
|
-- Handle environment stuff related to sleeping: skip night and thunderstorm
|
||||||
function mcl_beds.sleep()
|
function mcl_beds.sleep()
|
||||||
local storm_skipped = mcl_beds.skip_thunderstorm()
|
|
||||||
-- Always clear weather
|
|
||||||
if weather_mod then
|
if weather_mod then
|
||||||
mcl_weather.change_weather("none")
|
if mcl_weather.get_weather() == "thunder" then
|
||||||
end
|
local tod = minetest.get_timeofday() * 24000
|
||||||
if is_night_skip_enabled() then
|
if (tod < 18541 and tod > 5458) then
|
||||||
if not storm_skipped then
|
mcl_beds.skip_night()
|
||||||
mcl_beds.skip_night()
|
mcl_beds.kick_players()
|
||||||
|
else
|
||||||
|
-- Sleep for a half day (=minimum thunderstorm duration)
|
||||||
|
minetest.set_timeofday((minetest.get_timeofday() + 0.5) % 1)
|
||||||
|
mcl_beds.kick_players()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
mcl_beds.skip_night()
|
||||||
|
mcl_beds.kick_players()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Always clear weather
|
||||||
|
mcl_weather.change_weather("none")
|
||||||
|
else
|
||||||
|
if is_night_skip_enabled() then
|
||||||
|
mcl_beds.skip_night()
|
||||||
|
mcl_beds.kick_players()
|
||||||
end
|
end
|
||||||
mcl_beds.kick_players()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -287,16 +301,6 @@ function mcl_beds.skip_night()
|
||||||
minetest.set_timeofday(0.25) -- tod = 6000
|
minetest.set_timeofday(0.25) -- tod = 6000
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_beds.skip_thunderstorm()
|
|
||||||
-- Skip thunderstorm
|
|
||||||
if weather_mod and mcl_weather.get_weather() == "thunder" then
|
|
||||||
-- Sleep for a half day (=minimum thunderstorm duration)
|
|
||||||
minetest.set_timeofday((minetest.get_timeofday() + 0.5) % 1)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function mcl_beds.on_rightclick(pos, player, is_top)
|
function mcl_beds.on_rightclick(pos, player, is_top)
|
||||||
-- Anti-Inception: Don't allow to sleep while you're sleeping
|
-- Anti-Inception: Don't allow to sleep while you're sleeping
|
||||||
if player:get_meta():get_string("mcl_beds:sleeping") == "true" then
|
if player:get_meta():get_string("mcl_beds:sleeping") == "true" then
|
||||||
|
|
Loading…
Reference in New Issue