From d7a74560072b0e2c2b0f35b49cbd46a0a1852a4a Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 20 May 2016 11:40:15 +0100 Subject: [PATCH] Beds: Save respawn position when entering bed, only read bed spawns once 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 | 6 +----- mods/beds/spawns.lua | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mods/beds/functions.lua b/mods/beds/functions.lua index afc8e15a..c383a3f2 100644 --- a/mods/beds/functions.lua +++ b/mods/beds/functions.lua @@ -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 diff --git a/mods/beds/spawns.lua b/mods/beds/spawns.lua index 48b8a669..2e27f21a 100644 --- a/mods/beds/spawns.lua +++ b/mods/beds/spawns.lua @@ -37,6 +37,8 @@ function beds.read_spawns() end end +beds.read_spawns() + function beds.save_spawns() if not beds.spawn then return -- 2.25.1