Pros waitUntil help

*note Cata= the motor powering the catapult and CataStop= the limit switch used to tell the motor to stop spinning.

I’m a new PROS user and I’ve noticed that a lot of things are different. My main problem at the moment is that I’m trying to find the equivalent of a waitUntil() in vexcode pro to pros.

In autonomous, im to the point where I need to shoot my catapult, so wrote- Cata=127; to get it to spin through the slipgear, as one would. I want to add the line
Cata.spin(forward, 100, percent); ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ waitUntil(CataStop.pressing());‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ Cata.stop(coast);

This is what I had in Vexcode Pro. My question is- How would I program my catapult to do the same function in pros?

You can just make your own custom waitUntil. This macro is basically the same as the one on vexcode:

#define waitUntil(condition) while (!(condition)) { pros::delay(50); }

Just put it in your main.h file and you can use it just like in vexcode.

Here is some sample code don’t know if it works or not but should help you out.
I broke the shoot and load actions into two functions.
You could combine if you want.

void shoot(bool bload){
 // 0 will stop the motor pos # forward neg # reverse
  // catMotor.moveVelocity(0);
 // Or you could do move relative like below.  
  catMotor.moveRelative(550,100);
// slight delay will let the cat fire.
  pros::delay(300);
// this is a bool (true false) to load
  if(bload){
    load();
  }
}

void load(){
    
    // std::cout << limitSwitch.get_value() << ": close..." << std::endl;
    // 0 or false is pressed
    // 1 or true is up
// putting this in a task allows the robot to drive around will the catapult loads
//  look into asynchronous non blocking code
  pros::Task task{[=] {

  while(true){
    
    if(limitSwitch.get_value()){
      // stop if the limit switch is hit.
       catMotor.moveVelocity(0);
       break;
       
    }else{
       catMotor.moveVelocity(100);
    }
     pros::delay(10);
   }
    }};

}

Where and how would I implement this? I’m interested in multitasking.

It’s called a lambda task. I learned about it here: Multitasking — PROS for V5 3.7.3 documentation