A good way to check if two items are present in the same room?

I want to create some special effect if two items are in the vicinity of each other (in the same room). If the items can be contained in different levels of containers, how do I recurse back up until I get to the ‘Room’ level? Is there a way to reflect on the object type?


Hi! There’s a Thing method called getOutermostRoom(). Also, the myObj.isIn(myRoom) method will return true regardless of whether it’s nested in containers.
You could potentially check in a beforeAction() or afterAction() or enteringRoom() or roomDaemon() (depending on what effect you’re looking for) if
or simply
if(obj1.isIn(certainRoom) && obj2.isIn(certainRoom)) /side effects/
Hope that’s what you’re looking for!

This is very helpful, thanks!!