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
ID:270514
Jun 4 2006, 4:06 am
|
|
How would I fo a for(), but I don't want the...- argh, let me explain it with code.
turf/Click() How would I go on excluding the clicked turf in the for()? Thanks, O-matic |
In response to Mysame
|
|
Better yet:
turf/Click() 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 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 |
if(T.x==src.x&&T!=src)