From: adrido Date: Tue, 12 Jul 2016 09:02:01 +0000 (+0200) Subject: Beds: Only register respawn callbacks if respawn is enabled X-Git-Tag: 0.4.15~132 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d89bb69a22e7abe90c80e827e07ea20a2c633a35;p=oweals%2Fminetest_game.git Beds: Only register respawn callbacks if respawn is enabled --- diff --git a/mods/beds/functions.lua b/mods/beds/functions.lua index 96cebe81..5eed27d9 100644 --- a/mods/beds/functions.lua +++ b/mods/beds/functions.lua @@ -173,19 +173,18 @@ end -- Callbacks - --- respawn player at bed if enabled and valid position is found -minetest.register_on_respawnplayer(function(player) - if not enable_respawn then - return false - end - local name = player:get_player_name() - local pos = beds.spawn[name] or nil - if pos then - player:setpos(pos) - return true - end -end) +-- Only register respawn callback if respawn enabled +if enable_respawn then + -- respawn player at bed if enabled and valid position is found + minetest.register_on_respawnplayer(function(player) + local name = player:get_player_name() + local pos = beds.spawn[name] + if pos then + player:setpos(pos) + return true + end + end) +end minetest.register_on_leaveplayer(function(player) local name = player:get_player_name()