ID:178310
 
Hi. Can't find a working example on this one, and can't figure it out from the docs. I want to check whether a certain object exists in a defined area, without using coordinates. For example, the areas:

area/black
square1
desc = "Square One"
square2
desc = "Square Two"
square3
desc = "Square Three"

area/red
square1
desc = "Square One"
square2
desc = "Square Two"
square3
desc = "Square Three"

I want to test to see if my object "redstone" exists in, say, /area/black/square1. That area is many tiles in size, and the stone could be anywhere, so I don't want to specify coords. I've been trying variations on the theme:

for(var/obj/redstone/S in /area/black/square1)
if(S)
usr << "There is a red stone in Black's Square One."
else
usr << "No red stones there."

with no luck. It always comes back false...any ideas?

Thanks,

H
Go to BYONDbwicki andt here is a thing about mines, youc ould use that example.

BTW, how did you Find BYOND? Your key is pretty recent :)
In response to Sariat
Hi,

I found BYOND by looking for game-design resources on the web...an old hobby of mine, but I'm not a real programmer (yet).

As a newbie, I am also mystified by BYONDbwicki...what is that?

Thanks,

H
Humbabba wrote:
I want to test to see if my object "redstone" exists in, say, /area/black/square1. That area is many tiles in size, and the stone could be anywhere, so I don't want to specify coords. I've been trying variations on the theme:

for(var/obj/redstone/S in /area/black/square1)
if(S)
usr << "There is a red stone in Black's Square One."
else
usr << "No red stones there."

with no luck. It always comes back false...any ideas?

You're close on this, but there's one key problem. The reason this isn't working is that you're /area/black/square1 is a type path, not the area itself. A type path has no contents list.
What you need to do is to find the area--either by knowing a turf in that area and getting its loc, or by searching all areas of its type in the world.
for(var/area/black/square1/A in world)
var/obj/redstone/S
for(S in A) break
if(S) usr << "There is a red stone in Black's [A.desc]."
else usr << "No red stones there."

Lummox JR
In response to Lummox JR
Ah. That makes perfect sense...type path. Now I understand what that means.

Many thanks!

H