View Single Post
  #5   Spotlight this post!  
Unread 13-02-2015, 13:52
fireXtract fireXtract is offline
MegaHertz_Lux
FRC #2847 (Mega Hertz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: fmt
Posts: 42
fireXtract is an unknown quantity at this point
Re: Pneumatics, getting XBox input

Quote:
Originally Posted by Oromus View Post
The issue is that you need to change
Code:
if(XboxController.button[0] == true)
to
Code:
if(XboxController.button[0].get() == true)
The key change there being the addition of ".get()". What your code is doing is saying "If this button is true, run my code". A button won't be equal to true because it's a Button, not a boolean. Using "XboxController.button[0].get()" changes that line of code to "If this button's STATE is true (pressed), run my code". This should fix your problem.
In addition to what he stated, this would be as good a time to learn java operators as any.
A few common ones include

Code:
if (leftStick.getRawButton(5)) {} // if the button is held(or true) it would run the code
if (!leftStick.getRawButton(5)) {} // the ! operator inverts your boolean, so when the 5 button is not held it would run this code using the == true is a bit redundant when java interprets true as the default for running your if anyway and using ! would invert it to false.
if (leftStick.getRawButton(5) && rightStick.getRawButton(5)) {} // this would only run the if when left and(&&) right stick are both held
Reply With Quote