//Title: Top-Level Location Finding
//Credit to: Jtgibson
//Contributed by: Jtgibson
//Recursively searches locations upwards until it finds
// the appropriate location. For example, you can bury
// an obj inside a pouch inside a sack inside a user,
// and using obj.findloc(/obj/sack) will return the sack,
// even though the object's current location is a pouch.
//If the object is not in the area you specify, the proc will
// return null.
//This is primarily useful for determining the turf or area an
// object is in, regardless of whether it's in a container
// or not, or for finding the mob that currently possesses an
// obj, no matter how buried that obj is in the mob's inventory.
atom/proc/findloc(type)
if(istype(src, type)) return src
if(!loc) return null
if(istype(loc, type)) return loc
return loc.findloc(type)
ID:195129
Nov 21 2006, 7:39 am
|
|