blocking commands

I am not used to using broadcast to trigger scripts among robot components so I need clarification on something I’ve found confusing. Say I make an object avoidance robot with an ultrasonic sensor running a script like
forever if distance < 150 mm
broadcast backup
else
broadcast goforward
Then the motors have something like
when backup
spin rev
wait 3
(some code to turn)
when goforward
spin fwd
What I find is what should be a blocking function in the wait block is not affecting the timing of the ultrasonic sensor, so the sensor ignores the wait, immediately sees that the distance is now greater than the 150 mm threshold, and broadcasts goforward, interrupting the unfinished backup script. So an additional blocking wait must be put in the sensor script for the same amount of time to allow the motors to finish backing up.
Is this an accurate reading of what is happening?
Thanks,
Erik

I think you’re right. As soon as the robot gets over 150mm, it’ll send a ‘goforward’ message which will conflict with the already in process ‘backup’. You can achieve the same thing without using broadcast messages.

See pic:

d5deffdee3018e2ac67372da1ad601ec.jpg

Thanks, Damien. That makes sense. Conceptually I was trying to get my students adhere to the practice of robot components messaging each other to carry out their own associated tasks, but this raises timing issues. Your solution is much simpler!
Thanks,
Erik