setPageOffset in Corona not working

0 votes

I am trying to create a relative leaderboard in Corona where the user will see his score and other people's around him. I am following suggestions from this thread to do it.

Whenever I attempt to use setPageOffset the function will not have any paging performed. Instead, it returns a list starting from Rank 1 and down (the regular resposne as if no paging was given).

The code I used is as follows:

local pagingOffset = 10
local limit = 5
local scoreBoardService = App42API.buildScoreBoardService()
scoreBoardService.getTopNRankings(gameName, limit, App42CallBackMyRankList)


Could anyone shed light on this?

asked Oct 16, 2014 in App42 Cloud API-BaaS by thebattlebuddy (23 points)

1 Answer

0 votes


Please replace the below line from this metaHeadersParams.pageOffset = pageOffset

to metaHeadersParams.offset = pageOffset in App42Service.lua file which is in App42-Lua-API folder. 

Please make these changes and let us know if it helps.

Himanshu Sharma

answered Oct 16, 2014 by hs00105 (2,005 points)
I have made the change in App42Service, but it did not appear to make any difference in the result object. It still returns from the highest score and down with no offset.
Could you please put a below lines of code before calling leader-board api and share the logs with us:

local App42Log = require("App42-Lua-API.App42Log")

Himanshu Sharma
Sure thing. This is the response that is returned from debug. It is exactly the same response I would get from a normal request starting from rank 1 (aside form the signature).

    SignParams is : {"apiKey":"2105a43d6ffe1db332cf7d46107a122e436676f583373875cfac6
    signature is : qUpbhqyh5sOxvteoqIwOjAfEnZ4%3D
    Header Key is : SDKName   Header Value is : "Corona"
    Header Key is : apiKey   Header Value is : "2105a43d6ffe1db332cf7d46107a122e4366
    Header Key is : dataACL   Header Value is : ""
    Header Key is : jsonObject   Header Value is : "[]"
    Header Key is : resource   Header Value is : "game/scoreboard"
    Header Key is : selectKeys   Header Value is : "[]"
    Header Key is : sessionId   Header Value is : "3cc56a1c-1d69-4391-8dab-c8cbea3e3
    Header Key is : signature   Header Value is : "qUpbhqyh5sOxvteoqIwOjAfEnZ4%3D"
    Header Key is : timeStamp   Header Value is : "2014-10-21T02:45:39.000Z"
    Header Key is : version   Header Value is : "1.0"
    Request URI is :
    Success is : {"app42":{"response":{"success":true,"games":{"game":{"name":"Doubl
Thanks for sharing the logs details. Looks like your page offset is not set correctly in Leader-board call. Kindly use the below code snippet and let us know if it helps:

local gameName = "DoubleDiamondCherriesTest1"
local App42CallBack = {}
function App42CallBack:onSuccess(object)
            print("Game name is "..object:getName())
            if table.getn(object:getScoreList()) > 1 then
                        for i=1,table.getn(object:getScoreList()) do
                                    print("userName is : "..object:getScoreList()[i]:getUserName())
                                    print("score is : "..object:getScoreList()[i]:getValue())
                        print("userName is : "..object:getScoreList():getUserName())
                        print("score is : "..object:getScoreList():getValue())
function App42CallBack:onException(exception)
            print("Message is : "..exception:getMessage())
            print("App Error code is : "..exception:getAppErrorCode())
            print("Http Error code is "..exception:getHttpErrorCode())
            print("Detail is : "..exception:getDetails())
Himanshu Sharma
The code I have is set up the same way as what you have provided. I ran a step-by-step debug and found that the value passed into setPageOffset() was somehow nil when it actually got into the function itself. If I add a random variable in as another parameter the offset works as expected.

scoreBoardService:setPageOffset(3); --passes in nil
scoreBoardService:setPageOffset("not used", 3); --passes in 3 as first parameter

I'm not able to explain this phenomenon, but it makes it work. This may be something further on my end which I will have to look into. Thank you for your support!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on