for(var/mob/M in get_step(usr,dir))
Problem description:
Is there any more efficient way to find mob infront me?
ID:141514
Feb 12 2009, 6:46 am (Edited on Feb 12 2009, 7:12 am)
|
|
Code:
for(var/mob/M in get_step(usr,dir)) Problem description: Is there any more efficient way to find mob infront me? |
Feb 12 2009, 7:03 am
|
|
Not really. But there's no need for one.
|
Depends if you want to find a single mob or all the mobs or all mobs within a specific parameter.
|
In response to Spunky_Girl
|
|
Single, as there shouldn't be more than one
|
In response to Ripiz
|
|
You can then use locate()'s version of finding a specific object type within a container (needless to say, look it up); it just returns the first one it finds in it (there could be additional ones). It's equivalent to a for() loop like this:
for(var/object_type/V in Container) The efficiency increase is there, although not groundbreaking and this topic is pretty weird in itself; if you have some apparent slowdowns in your code, the problem is not there (ie, the for() line), but in the loop body (or elsewhere). You may also want to consider that it's feasibly possible for multiple mobs to occupy the same turf (though you may still prefer to simply process through one anyway). |
In response to Kaioken
|
|
I just was bit too lazy to code
for(var/mob/M in get_step()) But thanks for reply, I'll use that now |