ID:573750
 
(See the best response by Robertbanks2.)
Okay so I have an object called /obj/Doors/Metal_Door. Before it closes I would like it to make a check that there are no mobs at it's location but I've been 100% unsuccessful.

Objects unfortunately don't have oview() or view() and when I do var/mob/M = /mob if(M in contents) it can't find anything so I'm stumped. If it's not in the contents and I can't check what's visible then how can I check if there's anything there?

I also tried placing a temporary mob object at the doors location but for strange reason it was duplicating the player and leaving them in the doorway even though I specified a mob of type mob/Holder.

I don't know. Any help? Thank you.
You can use for(mob in loc) to find out if there is a mob there. When you reference an obj or mob's loc, it will use the turf that they're standing on or the container that they're in(such as a mob's inventory).
That worked great, thanks. Here's what I came up if you're interested, it's probably one of those cases where it's wrong but works.

                var/mob/M = /mob

var/Blocked = 1
while(Blocked)

var/Found
for(M in loc)
Found = 1

if(Found)
sleep(20)
else
Blocked = 0
Best response
There's some optimization to be done here. You could always just remove the last bit and the Found var and use continue/labels, like this:

obj/Doors/Close()
Can_Close: //This sets a label for the while(Blocked) loop
while(Blocked)
for(mob/M in loc) //Checks for mobs in loc, obviously
sleep(20)
continue Can_Close //continues the while() loop
Blocked = 0
//close the door here


I imagine other people could further optimize this, but as far as I can tell(it's written from memory and untested), it should work fine.