ID:175831
 
How do I make it so that I have a turf on which a mob cannot fly over but fly over all other turf.
Coolroman123 wrote:
How do I make it so that I have a turf on which a mob cannot fly over but fly over all other turf.


Do you mean you cannot walk across it no matter what?
turf/my_turf/Enter()
return


~>Volte
In response to Volte
Something to the effect of:
mob/var/flying // a variable to test if a mob is flying

turf/noflyzone // the turf that does not allow flying mobs to enter it
Enter(atom/O)
if(ismob(O)) if(O:flying)
return 0 // Don't allow flying mobs to enter this turf
return ..() // You can change this to return 0 if you do not want anyone to enter this turf

turf // any other turf
Enter(atom/O)
if(ismob(O)) if(O:flying)
return 1 // If a mob is flying, allow it to enter this turf, regardless of whether or not the turf is dense
return ..()


Note: if you define Enter() for other turfs, be sure to include the bit about the flying, or finish it with return ..(), otherwise your flying mobs will not be treated as flying when trying to enter those turfs.


DerDragon
In response to DerDragon
GAH! COLON BAD!

Also, it's Enter(atom/movable/A) not Enter(atom/A). Atoms can't move.
In response to Garthor
Garthor wrote:
GAH! COLON BAD!

No, colon good. He has used it correctly in this instance. I'm sure he didn't define the variable 'flying' directly under atom. Colon is very useful at multiple times. You just need to learn to use them right, so they aren't harmful or unstable.

~>Volte
In response to Volte
It's still better to do a type-casting.
In response to Garthor
You have a point, and it is well taken. Though the colon is still fine in this case, chances are he's not going to have flying objs.