ID:270514
 
How would I fo a for(), but I don't want the...- argh, let me explain it with code.

turf/Click()
for(var/turf/T in world)
if(T.x==src.x)
T.icon_state="blownup"


How would I go on excluding the clicked turf in the for()?

Thanks,

O-matic
... You disappoint me, O!
if(T.x==src.x&&T!=src)
In response to Mysame
Better yet:
turf/Click()
for(var/turf/T in block(locate(src.x, 1, 1), locate(src.x, world.maxy, world.maxz)) - src)
T.icon_state="blownup"


That block instruction returns a list of all turfs with the same x value as src and "- src" subtracts the clicked turf from that list. The loop will be extremely smaller and the if statement is removed for even more efficiency.
In response to Mysame
Sorry! I was like, uh - a bit tired. In some code of mine - I made a dumb mistake. I did a if(T==src)return, after a for() loop. That's where it came from. >_>

Anyway, a bit off-topic - but I have a bit of a problem
here. This proc below, is supposed to set densities of trees and such. If a turf under src(which could be i.e. a treetop, with a layer of +1 or more) has a density of 1, src's density is set to 1 too. But, this is not happening. Because it fails to find any turf in its own location, except for itself. My question: Why?
proc
densitycheck(turf/src)
sleep(10)
for(var/turf/t in world)
if(t.x==src.x&&t.y==src.y&&t.z==src.z&&t!=src)
if(t.density)
src.density=1
else

src.density=0


O-matic
In response to O-matic
O-matic wrote:
Because it fails to find any turf in its own location, except for itself. My question: Why?

Simple, there can only be one turf per tile. Make them objects.
In response to Justin Knight
If I thought of that, before that half hour of stress, it could have saved me from alot... Ah well. Thanks, anyway.

O-matic