Webcore is essentially a scripting language for SmartThings, it’s likely to be your best bet anytime you want a stacked conditional.
That said, from a network engineering point of view I feel obligated to point out that SmartThings primarily uses mesh networks, Z wave and Zigbee. These do not guarantee forced sequencing. Messages can and do bounce around the network a little bit before they are delivered to the hub, which means getting very precise timing for anything under one minute is often difficult.
It is entirely possible that you might walk past the motion sensor, then open the door, but the hub might receive the “door opened” message before receiving the “motion detected” message. So this particular technology is not really a good match for trying to determine direction based on which device fires first. You can try it using web core, but it won’t be guaranteed to work every time.
See, for example, the following discussion (this is a clickable link)
So it’s not so much writing groovy that is the issue as the technology you are writing it for. Mesh networks are intended for tiny messages sent infrequently. Not for continuous command and control designs, which is usually what you are looking for when determining direction.
But you can certainly try it and see how it works for you.