Skip to content
Snippets Groups Projects
Unverified Commit abe1b9f5 authored by Paramat's avatar Paramat Committed by GitHub
Browse files

Spawn mod: Also reposition players on respawn

To avoid respawn position being possibly very distant from new player
spawn position.
parent bcf76eab
No related branches found
No related tags found
No related merge requests found
......@@ -106,19 +106,28 @@ local function search()
end
-- On new player spawn
-- On new player spawn and player respawn
-- Search for new player spawn once per server session. If successful, store
-- position and reposition new players, otherwise leave them at engine spawn
-- Search for spawn position once per server session. If successful, store
-- position and reposition players, otherwise leave them at engine spawn
-- position.
minetest.register_on_newplayer(function(player)
local function on_spawn(player)
if not searched then
success = search()
searched = true
end
if success then
player:setpos(spawn_pos)
player:set_pos(spawn_pos)
end
end
minetest.register_on_newplayer(function(player)
on_spawn(player)
end)
minetest.register_on_respawnplayer(function(player)
on_spawn(player)
return true
end)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment