ID:157048
 
Problem:
    if(/obj/piece/ in locate(x,y,1))
t<<"You cannot place a stone on an existing stone."
return

I am only looking to see if there is 1 object in the location, however this doesn't work, The only way I can check to see if their is a piece on the location is to use:
    for(var/obj/piece/p in locate(x,y,1))
t<<"You cannot place a stone on an existing stone."
return

However that's creating a variable which will never be used which is a bit wasteful, isn't there a shorter way which a new variable will not have to be created?

Note: The first code compiles fine, so I'm not sure if it's a bug or my own fault. The second code does work for what I am trying, but I hate creating things that will never be used anyways.
well you used locate in the wrong way, its...
if(locate(/obj/piece/) in loc) //so yea...
t<<"blah blah"
return
In response to Masschaos100 (#1)
I'll be damned.. I was checking to see if the object was in the location of x,y,1, never thought to compare it...using in... like that... Thanks.
In response to Leur (#2)
Leur wrote:
I'll be damned.. I was checking to see if the object was in the location of x,y,1, never thought to compare it...using in... like that... Thanks.

No, you were checking if the TYPE PATH was in the turf returned by locate(). Which is wasn't. Because type paths cannot be in the contents of atoms.
In response to Garthor (#3)
Was talking with someone about this on IRC, was confused at why locate(/obj/piece)worked but not /obj/piece, and now you cleared me up on it. Thanks.