Here is some code Easy saving of score, high score, resetting highscore

https://drive.google.com/#folders/0B1AJN63yjpDzUTcySG9IejVzSEE

There you go. No I don’t want to use gist, or whatever it is. I want to share it, so rather than mess around I just post it up here. 

Originally Created by Peach Pellen. I had to dig this up as it doesn’t exist anymore

on the net (everyhing is erased off the website). I had this sitting around, so it’s go time

Modified by Nicholas Golden in January 2014. While there are more complex implementations out there

This I found was the easiest. 

For what it’s worth, the other things I was messing with several other libraries, but I found that too confusing.

I’m not saying I was confused on how to use it (although, after 10 minutes, I didn’t figure it out)

I just think I needed something simple. 

How I’m currently using it you may ask? Simply, I have a series of short apps I have and needed to show

current high score, and if it was beaten to overwrite that. Oh and also I’d like it to save that data. 

Additionally, I use that score stuff to pass out to gamecenter. So as you can see, if that’s what you are 

after, then hey have a party. I have found there isn’t any limit to it. 

If you feel crazy, you can go the json route. I don’t care about that, I use what works for me. 

The beauty of this simple “ego” is you don’t have to know anything about the “back end” to use it. 

Just look at the main.lua, and you’ll see what’s going on. Then you can apply that to your own projects! 

When you start the app, notice “best” is at 0. As you click the click to score button, the score goes up, and so does the “best”. When you reload the app, the best will have a new value. As you click the score button again, if the score is less than the best, then best doesn’t change. If it’s greater than the best, then the best increments up. 

If you hit reset, just reload the app and best should be back to 0. That’s really all there is. 

Ok, so if you have questions twitter is easiest:

twitter:

@NicholasGolden

Change log: 

version 1.0

–removed package … seeAll since that’s now deprecated & changed to a table format, now everything plays nice :slight_smile:

version 1.1

–wrote a simple example to demonstrate the dead simplicity of it.

version 1.2 

–added a reset button to the project

–changed the default value to “0” since I was using it for highscore. in ego.lua, there is a file:write(“0”), that value is just there so something gets returned if there was no data. For example, you could put “empty” and it would show “empty” on screen, until a value was put in then it would populate. 

The best example is to look at the comments in the main.lua file. I’ll go ahead and leave the 

original comments below by Peach so you can see what the original comments were :slight_smile:

Fixed this so if it’s a first time running it, a value shows up. For some reason it was saying that it was trying to compare a nil value, I didn’t catch that before until I ran it on another mac. Should work spiffy now.

Fixed this so if it’s a first time running it, a value shows up. For some reason it was saying that it was trying to compare a nil value, I didn’t catch that before until I ran it on another mac. Should work spiffy now.