ID:161587
 
I just read Zilal's MUD tutorial, so I have game code similar to hers. I've tried several ways(locating the object when it's created, putting the object in the area's contents, etc.), and I was wondering how you make the object just spawn in the area?
By default the only parameter for atom.New() is the location to place it. so when you create it with new send the area as an argument. She has you set up your areas to have tags that match their names so it'll be easy for you to get a reference to that area. =)

Example:
mob/verb/Create_tattle_tale(area_name as text)
var/mob/tattle_tale/T=new(locate(area_name))
T.tattle()

mob/tattle_tale
proc/tattle()
world << "I'm in [loc]."


Now if you supply an area's name to the Create tattle tale verb it will be used by locate() to grab a reference to the area.
In response to YMIHere
I need the objects to spawn when the world is created, not when I tell them to. I tried making a spawn proc for the objects and looping through it based off of your example, but I forgot they have to exist to be acted upon by a proc.
In response to Darkmag1c1an11
Just create them in World/New() as Z did for the areas (after the areas get created of course). =)
In response to YMIHere
Alright, I got the objects to spawn, now I want a better way of seeing if they're in the area. It gets very annoying having a message telling you that there's objects in the area when there's nothing there. With that, I've tried:

if(A.contents) (Always returns true)

var/obj/O
if(O in A) (Always returns false)

var/obj/O
if(O in A.contents) (Always false)

if(A.contents.len) (Always true)

And none worked. Is annoying me pretty bad.
In response to Darkmag1c1an11
If you're trying to see if a specific type of object is in something's contents, do this:
if(locate(/obj/o) in A.contents)
In response to Popisfizzy
I'm looking for if any object is in the area.
In response to Darkmag1c1an11
If you mean /area, then just use that code with the /area.contents variable. If you mean "area" as in "region", then just loop through the turfs in that region and use the code provides on each turf's contents.