mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
Abort sleep if taking damage
This commit is contained in:
parent
38f6804a79
commit
8982e368ec
1 changed files with 15 additions and 0 deletions
|
@ -194,6 +194,7 @@ function mcl_beds.sleep()
|
|||
end
|
||||
end
|
||||
|
||||
-- Throw all players out of bed
|
||||
function mcl_beds.kick_players()
|
||||
for name, _ in pairs(mcl_beds.player) do
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
@ -201,6 +202,14 @@ function mcl_beds.kick_players()
|
|||
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()
|
||||
minetest.set_timeofday(0.25) -- tod = 6000
|
||||
end
|
||||
|
@ -305,3 +314,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
mcl_beds.sleep()
|
||||
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 a new issue