In this page:http://docs.coronalabs.com/guide/cloud/leaderachieve/index.html#leaderboard-methods
there is this code:
local function leaderboardsListener( event )
if ( event.type == “getScores” and event.error == nil ) then
local scoreStrings = {}
local results = event.results
local maxScores = #results
if ( maxScores > 10 ) then maxScores = 10 end --get maximum of 10 high scores
for i = 1, maxScores do
local text = string.format( “%-2d - %-15s - %6d”, i, string.sub(results[i].username, 1, 15), results[i].value )
scoreStrings[i] = display.newText( text, 0, 0, nil, 16 )
scoreStrings[i].x = display.contentCenterX - 32
scoreStrings[i].y = 100 + i * 24
end
end
end
end
where I found some problems:
First of all one “end” should be removed because there are 5 ends (one is in the same line of the if (maxScore > 10)
This is not so difficult to find as error, but I’m just wondering if this code was ever tested. Before to copy and paste a code I would test it.
Second problem:
local results = event.results
is wrong, should be
local results = event.response
based on other info found in another piece of code…
event.results is giving me an error
Third problem is that the test
if ( event.type == “getScores” and event.error == nil )
where even.error == nil is not working for me.
Adding the line:
print(“in leaderboardsListener event.name:”,event.name," event.type:",event.type," event.error:",event.error," event.response:",event.response )
I have this output:
in leaderboardsListener event.name: leaderboards event.type: getScores event.error: nil event.response: {“error”:“User authentication token is not present in the request parameters.”}
So the event.error is nill but still I have an error that is indicated in the even.response
Now obviously I’m doing something wrong… but I do not understand what.
Also, when I try to see the scores in the leaderboard in the cloud dashboard I do see only a white page (i’m clicking on the link Score in this leaderboard).
I think (but I’m not sure) I’ve submitted a score, but I’m not able to see this neither via code, nor via the dashboard…
Thank you,
Ema