Potential bed error.

This commit is contained in:
Duane 2016-07-17 17:36:41 -05:00
parent 01cef3d1bd
commit 538243d697

View file

@ -247,6 +247,11 @@ minetest.register_chatcommand("sleep", {
return
end
if (beds.player and beds.player[player_name]) then
minetest.chat_send_player(player_name, 'You can\'t sleep.')
return
end
local pos = player:getpos()
if not pos then
return
@ -255,11 +260,18 @@ minetest.register_chatcommand("sleep", {
beds.on_rightclick(pos, player)
minetest.after(5, function()
local time = minetest.get_timeofday()
if not time or time < 0.23 or time > 0.3 then
return
end
local hp = player:get_hp()
if hp and type(hp) == 'number' then
player:set_hp(hp - 1)
end
minetest.chat_send_player(player_name, 'You\'d sleep better in a bed.')
end)
end,
})