Skip to content

Commit

Permalink
Beds: Save respawn position when entering bed, only read bed spawns once
Browse files Browse the repository at this point in the history
No longer require night to be skipped for resawn position to be saved
Remove constant beds.read_spawns() calls when a player joins as this
is only required once
  • Loading branch information
tenplus1 authored and paramat committed Jul 13, 2016
1 parent b749549 commit d7a7456
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 1 addition & 5 deletions mods/beds/functions.lua
Expand Up @@ -130,7 +130,6 @@ end

function beds.skip_night()
minetest.set_timeofday(0.23)
beds.set_spawns()
end

function beds.on_rightclick(pos, player)
Expand All @@ -149,6 +148,7 @@ function beds.on_rightclick(pos, player)
-- move to bed
if not beds.player[name] then
lay_down(player, ppos, pos)
beds.set_spawns() -- save respawn positions when entering bed
else
lay_down(player, nil, nil, false)
end
Expand All @@ -174,10 +174,6 @@ end

-- Callbacks

minetest.register_on_joinplayer(function(player)
beds.read_spawns()
end)

-- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player)
if not enable_respawn then
Expand Down
2 changes: 2 additions & 0 deletions mods/beds/spawns.lua
Expand Up @@ -37,6 +37,8 @@ function beds.read_spawns()
end
end

beds.read_spawns()

function beds.save_spawns()
if not beds.spawn then
return
Expand Down

0 comments on commit d7a7456

Please sign in to comment.