From b2c104d53ac516ad80a5a4c1716bacf2ecd322ce Mon Sep 17 00:00:00 2001 From: Duane Date: Mon, 18 Jul 2016 17:46:07 -0500 Subject: [PATCH] Prevent bed errors in /sleep. --- chat.lua | 26 ++++++++++++++------------ goblin.lua | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/chat.lua b/chat.lua index 966f666..df1f294 100644 --- a/chat.lua +++ b/chat.lua @@ -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, }) diff --git a/goblin.lua b/goblin.lua index 7d32f48..1503a52 100644 --- a/goblin.lua +++ b/goblin.lua @@ -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