forked from minetest/minetest_game
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
This commit is contained in:
parent
b74954969c
commit
d7a7456007
@ -130,7 +130,6 @@ end
|
|||||||
|
|
||||||
function beds.skip_night()
|
function beds.skip_night()
|
||||||
minetest.set_timeofday(0.23)
|
minetest.set_timeofday(0.23)
|
||||||
beds.set_spawns()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function beds.on_rightclick(pos, player)
|
function beds.on_rightclick(pos, player)
|
||||||
@ -149,6 +148,7 @@ function beds.on_rightclick(pos, player)
|
|||||||
-- move to bed
|
-- move to bed
|
||||||
if not beds.player[name] then
|
if not beds.player[name] then
|
||||||
lay_down(player, ppos, pos)
|
lay_down(player, ppos, pos)
|
||||||
|
beds.set_spawns() -- save respawn positions when entering bed
|
||||||
else
|
else
|
||||||
lay_down(player, nil, nil, false)
|
lay_down(player, nil, nil, false)
|
||||||
end
|
end
|
||||||
@ -174,10 +174,6 @@ end
|
|||||||
|
|
||||||
-- Callbacks
|
-- Callbacks
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
beds.read_spawns()
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- respawn player at bed if enabled and valid position is found
|
-- respawn player at bed if enabled and valid position is found
|
||||||
minetest.register_on_respawnplayer(function(player)
|
minetest.register_on_respawnplayer(function(player)
|
||||||
if not enable_respawn then
|
if not enable_respawn then
|
||||||
|
@ -37,6 +37,8 @@ function beds.read_spawns()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
beds.read_spawns()
|
||||||
|
|
||||||
function beds.save_spawns()
|
function beds.save_spawns()
|
||||||
if not beds.spawn then
|
if not beds.spawn then
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user