Potential bed error.
This commit is contained in:
parent
01cef3d1bd
commit
538243d697
1 changed files with 17 additions and 5 deletions
12
chat.lua
12
chat.lua
|
@ -247,6 +247,11 @@ minetest.register_chatcommand("sleep", {
|
||||||
return
|
return
|
||||||
end
|
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()
|
local pos = player:getpos()
|
||||||
if not pos then
|
if not pos then
|
||||||
return
|
return
|
||||||
|
@ -255,11 +260,18 @@ minetest.register_chatcommand("sleep", {
|
||||||
|
|
||||||
beds.on_rightclick(pos, player)
|
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()
|
local hp = player:get_hp()
|
||||||
if hp and type(hp) == 'number' then
|
if hp and type(hp) == 'number' then
|
||||||
player:set_hp(hp - 1)
|
player:set_hp(hp - 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(player_name, 'You\'d sleep better in a bed.')
|
minetest.chat_send_player(player_name, 'You\'d sleep better in a bed.')
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue