Errors with ')' and ';'

Understanding the language, error messages, etc.

Re: Errors with ')' and ';'

Postby IPaulasaurus » Tue Jan 10, 2017 11:48 pm

Dude, I want this shiny chance program! That is really cool. I just got my shiny charm on Sun. So that'd be helpful
User avatar
IPaulasaurus
 
Posts: 22
Joined: Sun Dec 25, 2016 3:31 pm
Location: Deeeeeeeeeeeeeeeeeep Space

Re: Errors with ')' and ';'

Postby Xenospark » Wed Jan 11, 2017 9:04 pm

IPaulasaurus wrote:Dude, I want this shiny chance program! That is really cool. I just got my shiny charm on Sun. So that'd be helpful

Yeah haha You caught what I was using it for! Problem is, the rates are so messed up with the method that I definitely don't have the ability to code in a counter. After it exceeds 255, the odds reset back to standard. One problem in coding this is that the probability would be 71/1365 or whatever the rate is with charm and no SOS boost. I'm not sure how I would code this, so after reaching over 255 more accurate results I would just reset the chain :/
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Re: Errors with ')' and ';'

Postby Xenospark » Wed Jan 11, 2017 9:07 pm

Sorunome wrote:I'm sorry it took so long to reply. I'm a bit confused right now as to what you are mean, would you mind posting your entire code that you are running currently?

Sure, one problem is that I recently purchased a new computer, and didn't want to do a memory transfer for I had a TON of stuff on my previous computer that was just taking up space. I have yet to transfer my Coding/programming stuff over, and once I do I can put it here right away. Sorry for the inconvenience, and thanks again for willing to help!
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Re: Errors with ')' and ';'

Postby Xenospark » Thu Jan 12, 2017 3:52 pm

Sorunome wrote:I'm sorry it took so long to reply. I'm a bit confused right now as to what you are mean, would you mind posting your entire code that you are running currently?

Alright, this is the code I am running as of now.
Code: Select all
//imports the SPI library (needed to communicate with Gamebuino's screen)
#include <SPI.h>
//importe the Gamebuino library
#include <Gamebuino.h>
//creates a Gamebuino object named gb
Gamebuino gb;

//declare all the variables needed for the game :
int chain = 1;
float chance = 0;
int fchain = 1;
void setup() {
  // put your setup code here, to run once:
  // initialize the Gamebuino object
  gb.begin();
  // show the start menu
  gb.titleScreen(F("Shiny Probability"));
  //random values
  pinMode(chain, OUTPUT);
}
void reCalcChance() {
  if (chain <= 69) {
    chance = chain / 4096.0;
  }
  if (chain >= 70) {
    chance = chain / 1024.0;
  }
  if (chain >= 256) {
    chain = 1;
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  if (gb.update()) {
    //prints Chain length on the screen
   
    if (gb.buttons.pressed(BTN_A)) {
      chain = chain ++;
      fchain = fchain ++;
      reCalcChance();
    }
    if (gb.buttons.pressed(BTN_B)) {
      chain = chain --;
      fchain = fchain --;
      reCalcChance();
    }
   
    gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.print(F("Chance of Shiny:"));
    gb.display.println(chance*100);
  }
}

Hope this helps. I haven't tried it in a while but I'm sure it hasn't changed haha
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Re: Errors with ')' and ';'

Postby Sorunome » Thu Jan 12, 2017 4:38 pm

You have to do just "chain++;" or "chain--;", NOT "chain = chain++;"
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Errors with ')' and ';'

Postby Xenospark » Thu Jan 12, 2017 7:37 pm

Sorunome wrote:You have to do just "chain++;" or "chain--;", NOT "chain = chain++;"

Works like a charm! Thanks a ton man! Is there a way that I can make it display the "chance" below the line that it says chance of shiny?
What I mean is:
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.print(F("Chance of Shiny:"));
    gb.display.println(chance*100);

is what I'm using now and it reads on the screen like
Chain Length: x
Chance of Shiny: 0.0x

would changing the code to:
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.print(F("Chance of Shiny:"));
    gb.display.print(chance*100);

Would it read as:
Chain Length: x
Chance of Shiny:
0.0x

Thanks again for all the help! I'm glad to see it working and its all thanks to you!
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Re: Errors with ')' and ';'

Postby Sorunome » Thu Jan 12, 2017 8:46 pm

Yeah, the difference between println and print is that println will add a linebreak after printing your text.
So what you'll want is:
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.println(F("Chance of Shiny:"));
    gb.display.print(chance*100);


EDIT: You can also add a linebreak with \n, so that you do like
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.print(F("Chance of Shiny:\n"));
    gb.display.print(chance*100);
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Errors with ')' and ';'

Postby Xenospark » Fri Jan 13, 2017 4:01 pm

Sorunome wrote:Yeah, the difference between println and print is that println will add a linebreak after printing your text.
So what you'll want is:
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.println(F("Chance of Shiny:"));
    gb.display.print(chance*100);


EDIT: You can also add a linebreak with \n, so that you do like
Code: Select all
gb.display.print(F("Chain Length:"));
    gb.display.println(fchain);
    gb.display.print(F("Chance of Shiny:\n"));
    gb.display.print(chance*100);

Once again, it works great! I couldn't get the first variation you typed to work, but the \n worked fine! And did you say there was no way to make it show more than two zeroes past the decimal, and the only way to get farther down the line was doing *100? If that is the only way to do it then it is done! Otherwise, I would like to see if it can read as 0.0002348 or whatever the odds would be.
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Re: Errors with ')' and ';'

Postby Sorunome » Sun Jan 15, 2017 5:34 pm

You could always just manually display your stuff, like
Code: Select all
gb.display.print(chance * 100); // displays stuff before the comma and two decimals
gb.display.print(((uint32_t)(chance * 1000000)) % 100); // display next two decimals
gb.display.print(((uint32_t)(chance * 100000000)) % 100); // display next two decimals


I think. The code is untested
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Errors with ')' and ';'

Postby Xenospark » Mon Jan 16, 2017 2:31 pm

Sorunome wrote:You could always just manually display your stuff, like
Code: Select all
gb.display.print(chance * 100); // displays stuff before the comma and two decimals
gb.display.print(((uint32_t)(chance * 1000000)) % 100); // display next two decimals
gb.display.print(((uint32_t)(chance * 100000000)) % 100); // display next two decimals


I think. The code is untested

Works like a charm! All done then I think. Thanks a ton Sorunome, you were a huge help!
Xenospark
 
Posts: 16
Joined: Tue Dec 20, 2016 8:11 pm

Previous

Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 19 guests

cron