Is there a way to traverse a hierarchy backward?

xordevoreaux
Can we start at the child object and iterate through all possible n tiers of parent until we get the type of parent container we want?
Right now I'm looping through all objects down through the hierarchy and testing with Contains. That could get slow if I have a lot of objects in the game.

The Pixie
To get the parent of a child object, just look at the parent attribute. For example, player.parent is the room the player is currently in.

xordevoreaux
I basically want to go parent --> parent --> parent --> whups! stop, this one has the attribute I'm looking for, and it could be n parents away.

The Pixie
Look at the ListParents function
http://docs.textadventures.co.uk/quest/ ... rents.html

xordevoreaux
Looked at it. It returns an object list, that thing I can't get to in the GUI. Thanks anyway.

The Pixie
Go into code view for a script (say the start script on the game object) by clicking the nineth icon, and paste this in:
foreach (o, ListParents(player)) {
msg(o.name)
}
Then go back to the GUI view. You will find the GUI does successfully display it. It is only from the attributes tab that object list was missed off.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums