Don't allow to go to bed while player moves

This commit is contained in:
Wuzzy 2019-02-11 16:14:08 +01:00
parent 5a7952bf92
commit 49949e2f36

View file

@ -71,6 +71,14 @@ local function lay_down(player, pos, bed_pos, state, skip)
return
end
-- No sleeping while moving. This is a workaround.
-- TODO: Ideally, the player speed should be force-set to 0,
-- but this is not possible in Minetest 0.4.17.
if vector.length(player:get_player_velocity()) > 0.001 then
minetest.chat_send_player(name, "You have to stop moving before going to bed!")
return
end
-- No sleeping if monsters nearby.
-- The exceptions above apply.
-- Zombie pigmen only prevent sleep while they are hostle.