Saving and loading highscore

Hey guys i just finish Rob’s new tutorial on saving an loading scores, one part of the tutorial that was not clear was how to compare the last score to the current score and determine if its a new “highscore”. i went ahead and download the sample projects and implement this new style of saving scores into my code. the tutorial did mention something about high sore but it wasn’t clear to me. here is my code below 

local widget = require( "widget" ) local score = require( "score" ) scoreText = score.init({ fontSize = 20, font = "Helvetica", x = display.contentCenterX, y = 20, maxDigits = 7, leadingZeros = true, filename = "scorefile.txt", }) screenGroup:insert(scoreText) saveButton = widget.newButton({ width = 200, height = 64, x = display.contentCenterX, y = display.contentHeight - 64, label = "Load Score", labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0 } }, fontSize = 32, onEvent = loadScore }) screenGroup:insert( saveButton) function loadScore( event ) if event.phase == "ended" then prevScore = score.load() if prevScore then score.set(prevScore) end end return true end function scoreUpdate() score.add(100) end timer1 = timer.performWithDelay( 1000, scoreUpdate, - 1 ) function gameOver() -- here i would compare M.score in the score.lua file to the previous score. something like this --[[if M.socre is greater then prvous score then score.save() --]] storyboard.gotoScene("restart", "fade", 400) end --can someone help thanks :)

this line: if M.socre is greater then prvous score then

should perhaps be:

   local prevScore = score.load()

   if score.get() > prevScore then

        score.save()

   end

or something like that.

 

thanks Rob it work your a life saver

this line: if M.socre is greater then prvous score then

should perhaps be:

   local prevScore = score.load()

   if score.get() > prevScore then

        score.save()

   end

or something like that.

 

thanks Rob it work your a life saver