forked from minetest/minetest_game
Spawn mod: Also reposition players on respawn
To avoid respawn position being possibly very distant from new player spawn position.
This commit is contained in:
parent
bcf76eab1d
commit
abe1b9f559
@ -106,19 +106,28 @@ local function search()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- On new player spawn
|
-- On new player spawn and player respawn
|
||||||
|
|
||||||
-- Search for new player spawn once per server session. If successful, store
|
-- Search for spawn position once per server session. If successful, store
|
||||||
-- position and reposition new players, otherwise leave them at engine spawn
|
-- position and reposition players, otherwise leave them at engine spawn
|
||||||
-- position.
|
-- position.
|
||||||
|
|
||||||
minetest.register_on_newplayer(function(player)
|
local function on_spawn(player)
|
||||||
if not searched then
|
if not searched then
|
||||||
success = search()
|
success = search()
|
||||||
searched = true
|
searched = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
player:setpos(spawn_pos)
|
player:set_pos(spawn_pos)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
on_spawn(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
on_spawn(player)
|
||||||
|
|
||||||
|
return true
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user