There are many ways to save data. If I’m being honest, my loadsave code, as happy as I am with it’s success is overkill if you are only saving one value. If you have much more complex save data, it’s great. Take a Lua table, save a JSON file with one line of code. Load it back in when the app starts and you have a table of settings.
But since I created that, we’ve added new API’s that make setting storage and retrieval a bit easier. Look at:
system.setPreferences() and system.getPreferences()
https://docs.coronalabs.com/api/library/system/setPreferences.html
https://docs.coronalabs.com/api/library/system/getPreference.html
But I don’t think storage of the value seems to be the main issue as much as it is tracking the current score value, the all time high score value, displaying the current score and displaying the all time high score.
For instance, you don’t need to store the current score. If your using modules for different scenes like using Composer, you may need to pass the current score value between your game scene and your game over/high score scene. You only need to store your all time high score. You need to test to see if your latest current score is greater than the all time high score and then store the high score if it’s higher.
The loadsave code is hard to mess up if you have a Lua table of values to save.
Rob