Bug in MODKit? Code does not continue after calling a broadcast statement.

So we are writing a fully autonomous mode when we select the touch LED. We have a little “subroutine” that we call to make right turns using the “Broadcast” command. But when we call it from our autonomous code, it will only execute commands up to and including this subroutine. It will not do anything afterwards. Why is that?

Here’s a sample of the code we wrote:

With Modkit, you need to remember everything happens in parallel - broadcast doesn’t act like a function, the code triggered by the broadcast will run and the code after the broadcast will also try to run as well but there is a conflict between the two (both are trying to control the drive motors at the same time)
You could put the forward 100mm in another new thread and call that with a broadcast at the end of the MAKERIGHTTURN.

Really? So you can’t make a routine that just makes turns? Instead you have to write all robot movement as separate broadcasts? That seems like a very convoluted and laborious way of writing code.

Can someone post some sample code on how to use ModKit in a fully autonomous way? Code that would “force” the robot to do things in a synchronized and predictable fashion. I heard someone placing wait calls between broadcast commands and another site recommending putting all robot movement commands within a new broadcast. What does everyone do for this?

I guess Modkit can be considered an event-driven language and it relies on a whole bunch of threads “listening” for triggers. I find younger students find it very logical but if you want a more traditional programming structure, use ROBOTC instead.

One thing I would say about Modkit and Scratch is that it is really not easy to debug large and complex programs but for more simple programs and learning basic logic, it makes a lot of sense and it is great for doing stuff that is event-triggered like from bumper switches or buttons on the remote for example.