ID:162067
 
Just checking to see if BYOND has a quick built in way of getting all the contents of a Z level?

So I can basically say "for(objs in level)", where level is the Z value?
proc
GetZObjs(level)
var/obj/list/ZContents=new list()
for(obj/O as obj in world)
if(O.z==level)
ZContents.Add(O)
return ZContents

If I didn't make any mistakes that should return a list of all the objs on level
In response to Nickr5
Not what he wanted, and var/obj/list/ZContents shouldn't even compile.

block() is the closest to what Obs wants.
In response to Garthor
Except block returns the contents of a 3D area, right? So that would return all of the Z levels instead of a specific one.

Looping through the objs in the world and checking for the right Z level should work.
In response to Nickr5
Hopefully there won't be a performance hit someday.
In response to Nickr5
Please read the Reference entry for block() again. And looping through EVERY SINGLE THING IN THE GAME is never a good idea.
In response to Garthor
Except I'm not just looking for any obj, I'm specifically looking for a specifc type of object. There may be a lot of that type of object in the world, but certainly not anywhere near the amount of total objects in the world.


Or does BYOND loop through everything anyway regardless of the type?
In response to Obs
If it's an operation you're going to be performing often, you're just better off keeping a bunch of lists yourself to keep track of them.
In response to Garthor
Garthor wrote:
If it's an operation you're going to be performing often, you're just better off keeping a bunch of lists yourself to keep track of them.

I used to do that, but it's an operation that only runs once every minute. Not nearly often enough.