Determining an Object's Parent

K

KH-SOS

Guest
Is there a built-in variable or function you can use to determine an object's parent?
For example, if I have an object that generates other objects into the room, and I have a number of different enemies (Black dragons, red dragons, shoe salesmen, existential guilt, etc...). If I had those enemies assigned to different parents (DragonsParent, SalesmenParent, etc), and I choose an exact enemy type to generate, is there some way to determine its Parent to allow for some enemy-class conditions?
I know there's lots of ways to handle the problem in other ways (like make a parentis variable in every enemy type's Create code), but for my specific use it would really just be easier to use object.parent or parentis = object_get_parenttype(instance), but I don't see anything built-in. Obviously the system has this function/variable, but it doesn't seem to be made accessible to programmers.
 
A

anomalous

Guest
You can use:
object_is_ancestor(obj, par);

Correct me if I'm wrong, but I think that it also is true only for the strict case of being a child. It will not be true if it's the same object.

This caught me when I first used it.
 
K

KH-SOS

Guest
Awesome, thanks folks. Here's hoping the Parents help page gets this function added to it :p
 

TheouAegis

Member
It's in the manual under "Objects". under the 002 Reference section. The 001 Reference section is for beginners. It's missing a lot of stuff.
 
Top