Prevent bed errors in /sleep.

This commit is contained in:
Duane 2016-07-18 17:46:07 -05:00
parent ae0886a397
commit b2c104d53a
2 changed files with 15 additions and 13 deletions

View file

@ -258,20 +258,22 @@ minetest.register_chatcommand("sleep", {
end
pos = vector.round(pos)
beds.on_rightclick(pos, player)
local status, err = pcall(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
if status then
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
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)
minetest.chat_send_player(player_name, 'You\'d sleep better in a bed.')
end)
end
end,
})

View file

@ -2,7 +2,7 @@
-- GOBLINS
---------------------------------------------------------------
local spawn_frequency = 500 -- 500
local spawn_frequency = 350 -- 350
local dig_freq = 5 -- 5
local trap_freq = 25 -- 25
local torch_freq = 2 -- 2