ID:157711
 
mob/verb/Object()
var/obj/build/B=locate() in src.loc
for(B)
if(/*Object Amount?*/>=6)
src<<"You cannot build more than 5 objects in this spot!"
return
else
var/O=new/obj/Build/BuildObject(src.loc)
etc etc etc...

That was just an example of what I want, but this is what I have, and I'm wondering if there's a way to make it work in a similar way to mine.
mob
Build1
verb
Dresser()
set category="Build"
if(locate(/obj/Build/Dresser) in loc) return//Prevents overlapping
var/a = new/obj/Build/Dresser(usr.loc)
a:owner = "[usr.key]"
var/n
for(var/obj/built/B in loc) n++ //loop through all the objects in loc, then add 1 to the amount
if(n >= 6) //etc.
Gotrax wrote:
> mob/verb/Object()
> var/obj/build/B=locate() in src.loc
> for(B)
> if(/*Object Amount?*/>=6)
> src<<"You cannot build more than 5 objects in this spot!"
> return
> else
> var/O=new/obj/Build/BuildObject(src.loc)
> etc etc etc...
>


I think you should re-learn DM in a very big way.
 var/obj/build/B=locate() in src.loc
for(B)

What is that? See:
for(var/obj/build/B in src.loc)

// or even

var/obj/build/B
for(B in src.loc)


Back to your code...
 for(B)
if(/*Object Amount?*/>=6)

Again: huh? See:
  1. Initialize a counter variable
  2. Loop through each object of type B in the location, increment the counter per each object
  3. Outside of the loop, check if the count exceeds your limit.


More of yours...
                var/a = new/obj/Build/Dresser(usr.loc)
a:owner = "[usr.key]"

Come on, man, that's bad, bad, bad.
                var/obj/Build/Dresser/a = new/obj/Build/Dresser(usr.loc)
a.owner = "[usr.key]"

// or even

var/obj/Build/Dresser/a = new(usr.loc)
a.owner = "[usr.key

Don't use the ":" operator. There are very rare cases when there's a decent reason to use it, and I doubt you'll come across any for a good while.
In response to Kaiochao
Whatever happened to the list len variable?

if(list.len > 6)
//do stuff
In response to Spunky_Girl
That wouldn't work because he is counting a specific type on the tile. Not everything on it.
Ex
if(loc.len > 6)
//do stuff

Counts everything on the turf
While
var/n
for(var/obj/built/B in loc) n++ //loop through all the objects in loc, then add 1 to the amount
if(n >= 6) //etc.

Only counts the /obj/built/ on the turf
In response to Chowder
I guess I didn't look that closely at them. My bad.
In response to Chowder
Chowder wrote:
> if(loc.len > 6)
>

Counts everything on the turf

Note that considering loc can only ever contain null or a location (which is always an atom, and is in fact just another term for atom), and len is a var of /list, that will never work right. You're looking for src.loc.contents.len.