ID:974307
 
(See the best response by Kaiochao.)
Code:
proc                    
Missile(obj/c , loc1 , loc2, speed = 10)
var/obj/i = new c.type
i.loc = loc1
walk_to(i,loc2,0,0,speed)
del i


Problem description:

I'm making my own Missile proc that works how I need it to, however I want walk_to to actually wait until it has completed before deleting i.

So I obviously tried this as well:

proc                    
Missile(obj/c , loc1 , loc2, speed = 10)
var/obj/i = new c.type

i.loc = loc1
while(!(i in loc2))
sleep(?)
step_to(i,loc2,0,speed)

del i
The smallest amount of time you can practically sleep() for is world.tick_lag.

sleep(world.tick_lag)
Er, sorry. The question had nothing to do with sleep. Neither Missile proc works. The latter example never recognizes that i has reached the target location (loc2).

Does that mean you didn't see any problems with the method?
In response to Speedro
Best response
Well, sleep(?) isn't going to work.
Is 'i' actually moving towards loc2?

Also (not related to the problem), why not use initial location syntax?
var/obj/i = new c.type(loc1)
sleep(?) is because I am just unsure how long to sleep if at all. i does move to the new position and then just sits there, meaning (i in loc2) never becomes true. Also I forgot about that initial location syntax - I used to use it all the time, I don't know why I forgot it.

Hrm, nevermind, I'm dumb for not debugging first. loc2 = mob, and not turf. Sorry and thanks for your time.

EDIT: I suppose I'm still unsure how long to sleep in this circumstance:

while(!(i in loc2))
sleep(1)
step_to(i,loc2,0,speed)
del i
In response to Speedro
When you set a walk() delay to 0, I think it rounds to world.tick_lag. I mean, I don't think there's a way to make an object move from one place to another instantly, taking obstacles into account for each step, using walk().

So yeah, you can sleep for a minimum of world.tick_lag. It defaults to 1.
Why don't you just make the missile an object and use the Bump() proc?
obj
Missile
icon='Whatever.dmi'
Bump(mob/M)
del(src)

and if you want it a ...timed missile,use the New() proc.