help with the Table LoadSave code bit..

First off, I’ll post my chunk of code that utilizes the “Table LoadSave” function found here , I think it was done by Rob…

I have the required ‘loadsave’ module also declared above this code chunk so that’s not the issue.

-------------- Updated ----------

&nbsp; &nbsp;local myHighScores = {} local function bestScoreLoadSave() &nbsp; local path = system.pathForFile( "saveTest33.json" , system.DocumentsDirectory ) &nbsp; local file = io.open( path, "r" ) &nbsp;&nbsp; &nbsp; if (file) then &nbsp; &nbsp; &nbsp;myHighScores = loadsave.loadTable("saveTest33.json", system.DocumentsDirectory) &nbsp; &nbsp; &nbsp;loadsave.printTable(myHighScores) &nbsp; end &nbsp; if myHighScores[score.currentLevel] == nil then &nbsp; &nbsp; myHighScores[score.currentLevel] = 0 &nbsp; end &nbsp;&nbsp; &nbsp; if myHighScores[score.currentLevel] \< score[score.currentLevel] then &nbsp; &nbsp; myHighScores[score.currentLevel] = score[score.currentLevel] &nbsp; &nbsp; loadsave.saveTable(score,"saveTest33.json", system.DocumentsDirectory) &nbsp; end end &nbsp; &nbsp; bestScoreLoadSave()

So what this is doing is printing:

Dec 29 19:44:17.658: table: 0x608000e63800 {

Dec 29 19:44:17.658:   [currentLevel] => 2

Dec 29 19:44:17.658:   [2] => 65.1

Dec 29 19:44:17.658: }

 

So it’s printing the correct values - but when it gets to:

&nbsp; if myHighScores[score.currentLevel] == nil then &nbsp; &nbsp; myHighScores[score.currentLevel] = 0 &nbsp; end

it’s always reverting to 0.  But in above example - “myHighScores[score.currentLevel]” should = 65.1… but it’s saying that it’s nil and making it 0… 

Am I accessing the table correctly?

Ahh OK finally figured this out, the last part:

loadsave.saveTable(score,"saveTest33.json", system.DocumentsDirectory)

I should have been saving the HighScores table not the score table… <RESOLVED>