Replicating vex brain handling multiple while loops

How does the vex brain handle running multiple while loops at once? I started in block code, and am now in the process of learning and transitioning over to coding in python. I know both relatively well now.

When I’m block coding, my code has three hat blocks (or three functions). When autonomous, when driver control, and when started. The last two both have a forever loop under them, and when I run the code (which I’ve done countless times over the season), has run perfectly. When I then translate it over to python text coding, it shows what I expect. The same functions, with a while True: statement.

My problem is when I go into another application to run unrelated python code. I used the same strategy, of creating multiple functions, and putting a while statement inside of them, except mine doesn’t work. It runs the first while statement, and then when it finishes, it runs the other.

How does vex do this, and why can’t I?

You need to use an instance of the competition class

1 Like

This is the website I’ve been looking at. I understand this part.

Sometimes though I’ve used two “when started” hat blocks and it’s handled that just fine too. That’s two while True: loops running at once. How is that handled, and how can I replicate it?

Thread

1 Like