Abort sleep if taking damage
parent
38f6804a79
commit
8982e368ec
|
@ -194,6 +194,7 @@ function mcl_beds.sleep()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Throw all players out of bed
|
||||||
function mcl_beds.kick_players()
|
function mcl_beds.kick_players()
|
||||||
for name, _ in pairs(mcl_beds.player) do
|
for name, _ in pairs(mcl_beds.player) do
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
@ -201,6 +202,14 @@ function mcl_beds.kick_players()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Throw a player out of bed
|
||||||
|
function mcl_beds.kick_player(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if mcl_beds.player[name] ~= nil then
|
||||||
|
lay_down(player, nil, nil, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function mcl_beds.skip_night()
|
function mcl_beds.skip_night()
|
||||||
minetest.set_timeofday(0.25) -- tod = 6000
|
minetest.set_timeofday(0.25) -- tod = 6000
|
||||||
end
|
end
|
||||||
|
@ -305,3 +314,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
mcl_beds.sleep()
|
mcl_beds.sleep()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||||
|
if hp_change < 0 then
|
||||||
|
mcl_beds.kick_player(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue