Is there a way to traverse a hierarchy backward?
xordevoreaux
19 Apr 2016, 19:18Can 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.
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
19 Apr 2016, 19:51To 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
19 Apr 2016, 20:43I 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
19 Apr 2016, 21:06Look at the ListParents function
http://docs.textadventures.co.uk/quest/ ... rents.html
http://docs.textadventures.co.uk/quest/ ... rents.html
xordevoreaux
19 Apr 2016, 22:03Looked at it. It returns an object list, that thing I can't get to in the GUI. Thanks anyway.
The Pixie
20 Apr 2016, 06:40Go 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.
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.