ID:875080
 
(See the best response by Zaoshi.)
Code:


Problem description:

I was wondering if there is a way to tell which turf a mob is standing on?
Best response
Variable loc is just a reference to the turf you're standing on.
I see.. well I'm trying to do something like this

        UpdateMobLocation()
for(var/mob/M in planetmobs)
if(M.loc == /turf/water)
world.log << "[M.name] is standing on water."
spawn(20)
UpdateMobLocation()


basically i'm trying to check for the turf they are ontop of but the if statement wont work.. no matter how i state it i checked the output of loc and it would say like "the water" "the sand"... but the thing is if i enter if(M.loc == "the water") or if(M.loc == "water") or as above in the dm tags it wont detect it.. is there any way to do this?
Where are you calling UpdateMobLocation() ?

I would throw this in an entered() or enter() statement under the turf, give the user the isonwater variable so it doesn't repeat remove the variable when they exit() the water.

Instead of running through ^ that which looks CPU intensive.
its actually not cpu intensive it doesnt spike at all even when scanning over 100 mobs already tested.

anyways any ideas?
I just gave you a great idea.

This should help - http://www.byond.com/ forum/?post=753901&hl=turf%20player%20is%20on

perhaps this - http://www.byond.com/ forum/?post=680526&hl=turf%20player#comment1861341

Still be easier using Enter and Exit ... you are making it complicated.