ID:141568
 
Code:
verb/Dig() // This verb is in an obj
usr << usr.loc // This is a debug line, I was trying to see what came up when I checked usr.loc
if(/turf/grass == usr.loc)
usr << "You dig a hole."
var/turf/hole/Hole/H = new(usr.loc)
usr << "You get some dirt."
var/obj/items/Dirt/D = new(usr)
if(/turf/swamp_grass == usr.loc)
usr << "You dig a hole."
var/turf/hole/HoleS/H = new(usr.loc)
usr << "You get some dirt."
var/obj/items/Dirt/D = new(usr)


Problem description:

It won't dig anywhere. I click the Dig verb, but nothing happens, except it return the grass turf through the output.

You are directly comparing a type path to an object instance, which won't ever evaluate to true since they are fundamentally different.
You might want to look into a built-in function called istype().
In response to Schnitzelnagler
for(var/turf/T in view(0,usr)) //or oview()
if(T.type == /turf/grass)
//etc

That would check to see if the turf under the player's type is whatever.
In response to Mizukouken Ketsu
Uhm, what exactly did you want to tell me (as you replied to my posting)?
And how should this code snippet help the original poster?
S/He simply wanted to compare the type of turf the player is currently located on with a given type and act accordingly.
In response to Mizukouken Ketsu
I think initializing a for() loop and calling a proc....is far far more inefficient than just using usr.loc...
You have to typecast it.

Like:
var/turf/A=usr.loc


Now you can make whatever changes to it you want as if it is a turf, which it is, usually, but still.
In response to Dragonn
That won't work because loc still won't be a type path. Also, loc is considered a turf by DM, anyway, so that won't do anything.

Besides, you don't need to typecast quick value checks like this, anyway.
In response to Schnitzelnagler
Editted by the way
Fixed. Thanks for your help.