ID:263440
 
Code:
    Dirt_Check()
for(var/turf/X in range(src,1))
for(var/obj/Dirt/D in oview())
spawn(3)
if(D in X)
..()
else
new/obj/Dirt(D)


Problem description:

Well here's how i want it to be, I want it so when this proc is activated if there is obj/Dirt on the ground, do nothing, but if there's not put a obj/Dirt on the ground
This should work.

    Dirt_Check()
for(var/obj/X in range(1,src))
if(istype(X,/obj/Dirt))
return
else
new /obj/Dirt(X)
In response to Masuko Shintaro
No it doesn't work, i'm not sure why
turf/verb/Dirt_Check()
if(!(locate(/obj/Dirt) in src.contents)) new/obj/Dirt(src)
In response to Masuko Shintaro
...You'd prefer a continue statement, to skip to the next loop iteration, rather than a return that will stop the entire proc.
Also, the 'else' is unneeded, since if the if() expression succeeded, it would never reach that 'else' anyway.

In addition, you're creating the /obj/dirt in X, which is INSIDE X, ie in X.contents. Rather, you will want to put it at X's turf (X.loc).


In the end, that whole loop isn't right. You're looping threw all objs at the range(), and if an /obj isn't 'dirt', you're creating a new 'dirt' at it's loc...what if there are multiple (or none at all!) /objs in the range(), etc.
In response to Android Data
He didn't elaborate on what he wanted enough, but I think it's more like this...
turf/proc/Dirt_Check()
for(var/turf/T in range(src,1))
if(!(locate(/obj/Dirt) in T))
new /obj/Dirt(T)

{If he doesn't want the 'src' turf to be checked as well, use orange())