From: Paramat Date: Thu, 7 Jun 2018 03:14:56 +0000 (+0100) Subject: Spawn mod: Also reposition players on respawn X-Git-Tag: 5.0.0~72 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=abe1b9f5598d8616ba7834372130acf6edbc035a;p=oweals%2Fminetest_game.git Spawn mod: Also reposition players on respawn To avoid respawn position being possibly very distant from new player spawn position. --- diff --git a/mods/spawn/init.lua b/mods/spawn/init.lua index ae8287f2..dc6366c1 100644 --- a/mods/spawn/init.lua +++ b/mods/spawn/init.lua @@ -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)