Storing Data

Wow. I can’t EVER get databases and JSON to work. I am at a loss. I have most of my game done, but now I need to store their high-score in some sort of storage file. The variable I want to store is one called s, which is their score. Can you guys help me save the variable s and pull it out of the file later. I do not have the pro, if that makes a difference.

Thanks in advance.

Saving things is easy, but you have to write some file I/O code.  You don’t need a database to make this work.  If you simply want to store a high score, then look at this recent tutorial we wrote:

https://www.coronalabs.com/blog/2013/12/10/tutorial-displayingsavingloading-scores/

It provides a simple to use scoring module, but you can pick off the file IO code from it.  I also wrote a tutorial for the easy saving and loading of Lua tables. You might want to go this route if you need to save more than a single score, like game settings (sound on/off, etc.)

http://omnigeek.robmiracle.com/2012/02/23/need-to-save-your-game-data-in-corona-sdk-check-out-this-little-bit-of-code/

Rob

Saving things is easy, but you have to write some file I/O code.  You don’t need a database to make this work.  If you simply want to store a high score, then look at this recent tutorial we wrote:

https://www.coronalabs.com/blog/2013/12/10/tutorial-displayingsavingloading-scores/

It provides a simple to use scoring module, but you can pick off the file IO code from it.  I also wrote a tutorial for the easy saving and loading of Lua tables. You might want to go this route if you need to save more than a single score, like game settings (sound on/off, etc.)

http://omnigeek.robmiracle.com/2012/02/23/need-to-save-your-game-data-in-corona-sdk-check-out-this-little-bit-of-code/

Rob