Handle getdistance on objects inside a container (Fixes #2046)