ID:160977
 
I have been working on a random re-spawning system. I have it almost ready for the first test but I can't figure out how to get the location of the specific turf I choose. My system works by getting all of turf X in world then adds the location to a list and then randomly chooses.
var/list/respawn = list()
proc/Random_Spawn()
while(1)
var/i = 0
while(i < 1)
var/c = /mob/NPC/Monster/Half_Zombie
for(var/turf/Earth/ground/Grass/G in world)
new c(locate(pick(respawn)))
i++
sleep(600)

As you can see I am missing the line to add the specific turfs location to the list but I can't seem to get it to work. I have searched the forum and read the refrence for clues and I am stumped.
Just setting the new mob's location to the turf will work, so you can remove that locate. I suggest you read up on locate() and the loc var. Also, why did you use a loop for something that will only be executed once? Another thing is that a loop like that should be a for() loop, not a while() loop.
In response to Jeff8500
Jeff8500 wrote:
Another thing is that a loop like that should be a for() loop, not a while() loop.

They're interchangeable, and probably end up being compiled exactly the same anyway - for() is just a quicker, more convenient way to set things up, but it makes no actual difference. If you will, something that would is to use simply var++ in the condition rather than in a separate statement, since that'd still work the same but process less.