ID:2391038
 
var/stepsToTake = rand(1,50)
for(var/i = 0, i <= stepsToTake, i++)
if(src.Interrupted == 1)
goto INTERRUPTED
else
step_rand(M)
for(var/turf/Water/W in world)
if(M.loc == W.loc)
world << "OH GOD DROWNING!"
sleep(8)



I'm not getting the output "OH GOD DROWNING!" when the mob enters the water. I'm wondering why not. Thank you!
The loc of a turf is always an area.
The loc of a mob (or any movable atom) on the map (as in, not inside another movable atom) is always a turf; the turf that it's standing on... such as a water turf.

If you're not using pixel movement, one simple way to check if you're standing in water is this:
if(istype(M.loc, /turf/Water))
world << "OH GOD DROWNING!"

Otherwise (if you are using pixel movement), you may be standing on multiple turfs at a time, so you could check like this:
if(locate(/turf/Water) in M.locs)
world << "OH GOD DROWNING!"

It's a huge waste of resources to potentially search through every water turf to check if it's equal to the turf that you already have a reference to (loc), when you could just use the reference itself.
I thought that istype compares argument 1 and argument 2 and checks to see if they're of the same type?
The f1 help function thing doesn't make sense to me. Would you mind explaining istype to me? Sorry about the nooby question.
In response to Matthewkind
If you're standing in water, then (by definition) M.loc holds a reference to some instance of /turf/Water.

istype(M.loc, /turf/Water) returns true iff M.loc is some instance of /turf/Water (including child types like /turf/Water/whatever).

The first argument to istype() is always an instance.
The second argument can also be an instance, but is usually a type.

Looking at the example in the DM Reference:
var/M
M = new/mob/ugly/duckling()
if(istype(M,/mob/ugly)) //this will be true
usr << "[M] is ugly!"

istype() returns true because /mob/ugly/duckling (the type of the first argument) derives from /mob/ugly (the second argument).
I guess my confusion here is that some Water tile is an instance of /turf/Water because it's an object that derives from that. But M.loc is a property of a mob, so I'm wondering how there is a correspondence between that property and that instance of this ideal Water.

I remember when I read through the guide (which I have done multiple times now, with varying degrees of understanding (the thing is super hard for me to understand at points)), I was always a little confused by this idea of containment.

In response to Matthewkind
Passing M.loc as the first argument to istype() simply passes the value of M.loc. You're not passing the variable "M.loc". Variables aren't passed around, only their contents are. All istype() sees is a reference to some atom or null, what M.loc's possible values are.
Another couple small tips:
1. Your first for() runs the code once more than stepsToTake because it starts at i=0 and ends after i=stepsToTake. Here's a simpler syntax:
for(var/i = 1 to stepsToTake)
i starts at 1 and counts up to stepsToTake before stopping.
2. Instead of goto, maybe break would work. But I don't know what comes after this loop.
3. Assuming your Interrupted var is meant to be a boolean variable (containing only 1 or 0), it's redundant to check if it's equal to 1. Also, if there's no local var named Interrupted, then the src. is unnecessary. Here's a simplified condition:
if(Interrupted)
My brain...
"Passing M.loc as the first argument to istype() simply passes the value of M.loc. You're not passing the variable "M.loc". Variables aren't passed around, only their contents are. All istype() sees is a reference to some atom or null, what M.loc's possible values are."

Is there any resource available for digging into this kind of thing? Contents of pre-defined variables, for example. BYOND seems really difficult to adapt to. I come from Java where the literals are either numbers, booleans, strings, or characters, if I remember correctly. So how do I think about the literals of BYOND in this context? Like, M.loc, what is the literal there?
In response to Matthewkind
The DM reference. When you're in Dream Maker, press F1 or go to "Help>Help On...". Everything built-in has an entry in there, and it's kept up to date, unlike the Guide.
Maybe it's the just the way I'm going about this, but I have a hard time understanding what the guide and reference are saying.
In response to Matthewkind
I come from Java where the literals are either numbers, booleans, strings, or characters, if I remember correctly. So how do I think about the literals of BYOND in this context? Like, M.loc, what is the literal there?

It sounds like you missed out on a pretty big part of Java: object-oriented programming.