Beds: Only register respawn callbacks if respawn is enabled
authoradrido <robots_only_adrido@gmx.com>
Tue, 12 Jul 2016 09:02:01 +0000 (11:02 +0200)
committerparamat <mat.gregory@virginmedia.com>
Fri, 15 Jul 2016 21:00:57 +0000 (22:00 +0100)
mods/beds/functions.lua

index 96cebe81608f2672fc897c74cb2656bb56be96da..5eed27d90aae40445c5d6c4c9c728f7d5a2ebace 100644 (file)
@@ -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()