Page 1 of 1
understanding spawn

Posted:
Tue Dec 16, 2014 00:38
by LocaL_ALchemisT
how does the game determine the spawn point?
how can we set our own random teleport point so that people wouldn't end up high above the sky or buried beneath the earth?
many thanks in advance
Re: understanding spawn

Posted:
Tue Dec 16, 2014 01:46
by Don
Re: understanding spawn

Posted:
Tue Dec 16, 2014 05:52
by paramat
Before any mapgen occurs Minetest picks random locations, starting at (x=0, z=0) and working outwards.
For each random location mapgen parameters and perlin noise are used to pre-calculate the ground level at that location, if that level is suitable (not underwater and not at high altitude) the player is then spawned in empty space at that (x, z) and with y = calculated ground level. Only then does the mapgen start generating terrain around the player.
If the random location is not suitable for spawn a new random location is chosen to be tested for suitability.
This means if the terrain is suitable at (x=0, z=0) the player will spawn there, but if there will be a mountain or ocean there the random locations gradually move outwards until a suitable altitude is found.
This way the player is always spawned at the closest suitable location to (x=0, z=0).
Re: understanding spawn

Posted:
Tue Dec 16, 2014 08:53
by ArguablySane
Is there a standard way to make the player spawn at ground level when the entire mapgen is being done by a mod? Moving the player after they spawn seems like it would work, but it isn't the most elegant solution.
Re: understanding spawn

Posted:
Tue Dec 16, 2014 15:18
by paramat
No standard way, my recent mapgens have spawnplayer functions that work in a slightly similar way to the core version: pre-calculate terrain from noise to find a suitable spawnpoint. But i need to change my functions to not depend on a chunk size of 80 nodes, i need to move towards the core method.