Beds: Save respawn position when entering bed, only read bed spawns once
authortenplus1 <tenplus1@users.noreply.github.com>
Fri, 20 May 2016 10:40:15 +0000 (11:40 +0100)
committerparamat <mat.gregory@virginmedia.com>
Wed, 13 Jul 2016 13:45:30 +0000 (14:45 +0100)
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

mods/beds/functions.lua
mods/beds/spawns.lua

index afc8e15adf979ef30061d0d8e634225138ad7b37..c383a3f2a22c7e174028251672fbb4c759730fcb 100644 (file)
@@ -130,7 +130,6 @@ end
 
 function beds.skip_night()
        minetest.set_timeofday(0.23)
-       beds.set_spawns()
 end
 
 function beds.on_rightclick(pos, player)
@@ -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
@@ -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
index 48b8a669428ebf991f553f4a951f8bcb03970bb5..2e27f21a34428bfb84b9c9cf364199d32b3d594d 100644 (file)
@@ -37,6 +37,8 @@ function beds.read_spawns()
        end
 end
 
+beds.read_spawns()
+
 function beds.save_spawns()
        if not beds.spawn then
                return