Real quick (from work 
This is what I put in main.lua on startup:
-- SETUP HIGHSCORES !!!
require("json")
local path = system.pathForFile( "highscores.txt", system.DocumentsDirectory )
-- io.open opens a file at path. returns nil if no file found
local file = io.open( path, "r" )
if file then
print("Highscore File Found!")
-- read all contents of file into a string
local contents = file:read( "\*a" )
highscoreTable = json.decode(contents)
print(highscoreTable[1])
io.close( file )
else
-- create file because it doesn't exist yet
print("Creating New Highscore File!")
file = io.open( path, "w" )
highscoreTable = {10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000}
local highscoreTableJSON = json.encode(highscoreTable)
file:write(highscoreTableJSON)
io.close( file )
end
And this is what I put on gameover:
-- check against highScore !!!
if score \< highscoreTable[10] then
-- not in the list so do nothing!
else
-- somewhere in the list!
local tempTable = {}
local counter = 0
local highscoreEntered = false
for i = 1, 10 do
if (score \> highscoreTable[i]) and (highscoreEntered == false) then
tempTable[i] = score
counter = counter + 1
highscoreEntered = true
else
tempTable[i] = highscoreTable[i-counter]
end
end
for i = 1, 10 do
highscoreTable[i] = tempTable[i]
end
end
-- save highScore to file!!!
local path = system.pathForFile( "highscores.txt", system.DocumentsDirectory )
print("Saving Highscore File!")
file = io.open( path, "w+" )
local highscoreTableJSON = json.encode(highscoreTable)
file:write(highscoreTableJSON)
io.close( file )
Basically I save the 10 highest scores. Go over this and see how that looks, for now. More info later if needed.
Thomas.
[import]uid: 70134 topic_id: 19648 reply_id: 75997[/import]