Vexcode function help

Hello, people of the vex forum, I hope you guys are doing well,

I am trying to write a function that uses parameters for the movement of tiles to make autons easier to program since at that point it becomes just knowing the route you want.

The problem I am encountering is not knowing how to get the user input of the function

If I were to call this function I would need to add the direction I want to move and how many tiles I want to move which would then get multiplied by however many milliseconds it would take to move 1 whole tile.

Below is the code I am using

int main() {

void moveTiles(directionType, tile) {

int tile;

cin >> tile (This is supposed to be how you get input for c++ but I don’t know anymore)

int distance = tile * how long it takes to move one tile;



Thanks in Advanced!!!

could you put it in the </> thing just so its easier to see

Here it is

20 characters

How are you trying to get user input? Controller buttons?

for the joysticks you can call a class function that’ll return the axis value between -127 and 127 like so:

and to check if a button is being pressed you call a similar function that returns true if the button is pressed:

1 Like

Sorry if I didn’t make it clear,

I’m not trying to get used input from the controller buttons but when you call a function you use parameters and I’m trying to use those parameters to calculate information

You could write some code that increases and decreases the value of a variable when you press the up and down buttons (showing the variable on the controller screen each time to keto track of it), then when you press a third button, calls the function you write with the current value of the variable.

Also, the API includes functions for spinning a motor a certain distance, please use those, It’ll be more accurate and consistent than converting to time.

1 Like

It’s for autonomous where I can use the parameters to calculate how far the bot travels


double distanceFunct(int input){


var = x;
var += y;
var -=z;
var = yadda yadda ya;
motor.spinFor(fwd, distanceFunct(var), deg);

Is this what you are looking for?


Yes thank you very much

Note that controller input during the autonomous period is prohibited (and blocked by vexos). So any parameters would have to be recorded and saved beforehand.

As I mentioned in other comments I would not be using controller values I would be using parameters of functions

Right but the point is that all controller input (even button presses) is ignored during the autonomous period, so if your plan is to press buttons on the controller to change how your robot behaves in the middle of auton, that is both technically impossible and prohibited by rule.

1 Like

Ok let me say it differently,

I don’t plan on using the controller in any way, shape or form durring the autonomous mode

Ah okay, sorry, I misunderstood your description.

No problem, I could have said it better