# X-Drive

Hello All. I am currently coding a X-Drive, and was wondering if something was possible. I am wondering if it is possible to give a multi-letter answer to a variable. basically something like “string LBF = fwd”. What I am trying to do, is make it easier to code autonomous for the X drive, because, for example, driving straight in autonomous would have 2 motors going forward, and 2 motors going reverse. I am trying to make this easier. If there is any other way to make that possible, I would take that advice too. I am just trying to make it as fast as possible. I will give an example after this.

"LeftBack.rotateFor(vex::directionType::LBF, 100, vex::velocityUnits::rev);
*LBF would be equal to fwd. The point would be to have a LBF, RBF, LFF, RFF. there would be one for every direction, for every drive motor.

I can explain this better if necessary.
Thank you all!

Correct if I’m wrong, but it looks like you are describing a function.

1 Like

I am not entirely sure what you are trying to do but here is a function that does what I think you mean.

``````void xdrive(directionType LBFd,directionType RBFd,directionType LFFd,directionType RFFd,double speed,int wt){
LBF.spin(LBFd, speed, pct);
RBF.spin(RBFd, speed, pct);
LFF.spin(LFFd, speed, pct);
RFF.spin(RFFd, speed, pct);
wait(wt, msec);
LBF.stop();
RBF.stop();
LFF.stop();
RFF.stop();
}
``````
1 Like

Here is a better example of it.

I kinda understand what you want to do now. The easiest and simplest way to do that is to go into the devices menu and reverse your RB and RF motors so that when you tell every motor to drive forward you will drive forward.

2 Likes

Correct me if I’m wrong, but isn’t it not necessary to include “vex::directionType::” and “vex::rotationUnits::” on every argument? I’m pretty sure you can just use LB.startRotateFor(fwd, 100, rev); and it’ll still recognize it.

1 Like

That is correct, but i like using it, as it makes it easier for my brain to decipher. I would change that if there is a problem, though.