Beds: Only register respawn callbacks if respawn is enabled

This commit is contained in:
adrido 2016-07-12 11:02:01 +02:00 committed by paramat
parent 9524ff67a3
commit d89bb69a22

View File

@ -173,19 +173,18 @@ end
-- Callbacks -- Callbacks
-- Only register respawn callback if respawn enabled
-- respawn player at bed if enabled and valid position is found if enable_respawn then
minetest.register_on_respawnplayer(function(player) -- respawn player at bed if enabled and valid position is found
if not enable_respawn then minetest.register_on_respawnplayer(function(player)
return false local name = player:get_player_name()
end local pos = beds.spawn[name]
local name = player:get_player_name() if pos then
local pos = beds.spawn[name] or nil player:setpos(pos)
if pos then return true
player:setpos(pos) end
return true end)
end end
end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()