Skip to content

Commit

Permalink
Beds: Only register respawn callbacks if respawn is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
adrido authored and paramat committed Jul 15, 2016
1 parent 9524ff6 commit d89bb69
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions mods/beds/functions.lua
Expand Up @@ -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()
Expand Down

0 comments on commit d89bb69

Please sign in to comment.