score.lua

im using the standard score.lua thats been around for a while.

when i goto my next scene im using:

  scoreText = score.init({fontSize =20, font= “Helvetica”, x=180, y = 12, maxDigits=6,leadingZeros=true,filename=“scorefile.txt”})

but the score is always zero even though i can see in the scorefile.txt that it is not zero

ive tried score.load, score.get and they all print with my score using the print statement

but the scores are never displayed.

should i not be using  :

 scoreText = score.init({fontSize =20, font= “Helvetica”, x=180, y = 12, maxDigits=6,leadingZeros=true,filename=“scorefile.txt”})

to do this? this seems to just reset the score to zero although it doesnt make sense to me because there is a number in the scorefile.txt

Calling score.init() initializes everything. That is it starts over at 0. You should only call this once.

After that, you have an object called scoreText and it should have methods to change the score: .set() - lets you set the value and .add() lets you add a value to the score.

scoreText.add( 10 )

would add 10 points to the score and it should automatically update the on screen display.

See: https://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/

Rob

Perfect. Thanks so much rob. It all makes sense now. I’ve been struggling trying to learn corona and lua on my own. Sometimes I just get stuck for days on simple things. Thank you for taking your time to answer such a basic question.

Calling score.init() initializes everything. That is it starts over at 0. You should only call this once.

After that, you have an object called scoreText and it should have methods to change the score: .set() - lets you set the value and .add() lets you add a value to the score.

scoreText.add( 10 )

would add 10 points to the score and it should automatically update the on screen display.

See: https://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/

Rob

Perfect. Thanks so much rob. It all makes sense now. I’ve been struggling trying to learn corona and lua on my own. Sometimes I just get stuck for days on simple things. Thank you for taking your time to answer such a basic question.