ID:157014
 
My respawn code is not working, help please
var/list/NextSpawn=list()
var/spawndelay=60
proc
AddSpawn(mob/M)
var/NS="[M.type]=[M.x],[M.y],[M.z]"
NextSpawn.Add(params2list(NS))

proc
SPAWN()
for(var/F in NextSpawn)
var/NEW=text2path("[F]")
var/mob/M=new NEW
M.loc=locate(NextSpawn[F])
NextSpawn.Remove(F)
sleep(1)
sleep(spawndelay)
SPAWN()

No errors or runetime errors are given
Where do you initiate the proc?
In response to Pirion
Proc is started when the world is created
Zashenel wrote:
My respawn code is not working, help please
No errors or runetime errors are given

What doesn't work about it?
Do you have any idea why its not working?
        var/NS="[M.type]=[M.x],[M.y],[M.z]"
NextSpawn.Add(params2list(NS))


This is going to add the list ("/mob/whatever"="1,2,3"). The text string "/mob/whatever" is not a type path, and the text string "1,2,3" is not an atom. So, trying to create an object of the type of the former won't work, and trying to locate it at the latter won't work.

Using an associative list at all here is not going to work. Instead, I suggest wrapping the respawn data in some datum and adding that datum to the list. For example:

respawnthingy
var/type
var/loc

proc/AddSpawn(mob/M)
var/respawnthingy/R = New()
R.type = M.type
R.loc = M.loc
NextSpawn.Add(R)


Also, your SPAWN() proc isn't looping properly. You should, instead, have:

while(1)
for(var/F in NextSpawn)
//etc.
sleep(spawndelay)