Im getting some errors I’m not sure how to fix. The code works fine in my other game but I’m having issues when I use the code in my new one. These are the errors that Im getting:
2014-05-06 17:30:26.753 Corona Simulator[473:507] Runtime error
/score.lua:30: bad argument #1 to ‘format’ (string expected, got nil)
stack traceback:
[C]: in function ‘format’
/score.lua:30: in function ‘set’
/restart.lua:42: in function ‘loadScore’
/restart.lua:80: in function </restart.lua:78>
?: in function ‘dispatchEvent’
?: in function <?:1096>
(tail call): ?
?: in function <?:481>
?: in function <?:218>
2014-05-06 17:30:26.851 Corona Simulator[473:507] Runtime error
/score.lua:30: bad argument #1 to ‘format’ (string expected, got nil)
stack traceback:
[C]: in function ‘format’
/score.lua:30: in function ‘set’
/restart.lua:42: in function ‘loadScore’
/restart.lua:80: in function </restart.lua:78>
?: in function ‘dispatchEvent’
?: in function ‘_listener’
?: in function <?:141>
?: in function <?:218>
and the code that its referring to:
[lua]function M.set( value )
M.score = value
M.scoreText.text = string.format(M.format, M.score) --Line 30
end
function loadScore()
local prevScore = score.load()
if prevScore ~= nil then
if prevScore <= mydata.score then
score.set(mydata.score) – Line 42
else
score.set(prevScore)
end
else
score.set(mydata.score)
score.save()
end
end
function scene:enterScene(event)
restartBttn:addEventListener(“touch”,restartGame)
loadScore() -Line 80
end
[/lua]
Any suggestions would be awesome!