ID:142362
 
Code:
turf
ladder
icon='Turfs.dmi'
icon_state="ladder"
Entered(mob/M)
M.loc = locate(x,y,2)
hole
icon='Turfs.dmi'
icon_state="hole"
Entered(mob/M)
M.loc = locate(x,y,1)
for(var/turf/dirt in M.loc)
if(T)
new/turf/ladder(M.loc)


Problem description:
So basically I want it so when you go through a hole if there is dirt below it makes a ladder(there are also things like water and path ways that I don't want a ladder to appear in) but when I use the above code it does not make a ladder it just moves the mob onto the dirt.
turf
icon = 'Turfs.dmi'

ladder
icon_state = "ladder"
Entered(atom/movable/a) a.loc = locate(x, y, 2)

hole
icon_state = "hole"
Entered(atom/movable/a)
a.loc = locate(x, y, 1)

if(istype(a.loc, /turf/dirt))
new/turf/ladder(a.loc)
As you probably know, M.loc is a turf. Therefore, your for() loop is broken because it's looking for turfs inside of a turf, but turfs can't contain other turfs - only /atom/movables (objs and mobs). You also have 2 more issues in your (unneeded) for() loop I'll cover for the sake of your knowledge; you have forgot to actually name the variable 'T' (as it is, the variable is defined as of type /turf and named 'dirt'), and you also needlessly check if the object (T) exists with that if statement - if there is no object, the code in the loop won't even be ran, so there is no point in checking it.

Like Popisfizzy's code does, since M.loc IS the turf, you're going to need to simply check M.loc's type.