ID:272746
 
What would be the best way to locate a spawn point on a map ?

I have several maps all sharing the same spawn point turf, but I want the player to start on the spawn point that's on the z location the player picked.

I can't get this to work, and neither do I want to make several turfs for each spawn point on each map.
Can you somehow narrow down the choice?
(E.g. A map being an area, or the player being within range(127) of the spawn point)
In response to Schnitzelnagler
I can do the second one, if I move them to the z layer they pick WHEN they pick it. What's your idea ?
In response to Andre-g1
Well, you can always
locate(SpawnPoint) in orange(127, PlayerMob)

though, the "bigger" the range, the slower things will get.
127 seems to be maximum of what I've read.

Edit:
On second thought, as you are likely to have only few spawn points, you could loop through a pre-made list and check their z var.
Might get you a better performance.

1. Create a list of spawn points on world New()
2. for(turf/SpawnPoint/S in spawns) if(S.z = PlayerMob.z)
3. PlayerMob.Move(locate(S))
In response to Schnitzelnagler
He could also use a loop or block:
proc/locateSpawn(map_z)
for(var/turf/Spawn/T in world)
if(T.z==map_z) return T


Or using block() instead of orange():
var/turf/Spawn/S = locate() in block(locate(1,1,map_z),locate(world.maxx,world.maxy,map_z))


I think using a loop may be more efficient in this case, but I'm not entirely sure. What you could do is create a Spawn_Points list, and add the Spawn Point turfs to the list using New(). Then you would just have to search that list, or sort it so you could index it (Spawn_Points[map_z])

*Edit*
Doh, you edited your post :(
In response to DarkCampainger
*smiles*
Edited to include that 3 minutes before you posted.
Two minds one idea!
Use the locate() function to locate specific tags var. :)
In response to Mizukouken Ketsu
Labelling the spawn points would mean a lot of manual work though, asides of the problem that he'd still have to compare the labels and the players position on the map.
So, it would be slow (strings involved, instead of numbers), it would require manual work and would be rather unpleasant to maintain or change later on.

Where exactly do you you see the advantage over the suggested system here?
In response to Schnitzelnagler
Since the maps are small (16x16), I'm going to opt to take the first suggestion. Thanks a lot. :)