Google Play load achievement description result

It looks like the callBack function is not being acessed no matter what. Do you know what can be causing this?

I would need to see a little bit of code where you call init(), but it could be a typo, code, or a scope issue.

Thank you so much for taking your time helping me!

Ok, so I have a myData.lua that stores all information and loads and saves settings.

I call myData.init() in my main.lua, after making the Google Play login.

-- Init game network to use Google Play game services gameNetwork.init("google") -- Tries to automatically log in the user without displaying the login screen if the user doesn't want to login gameNetwork.request("login", { userInitiated = false }) myData.init() composer.gotoScene( "menu" )

At the end of myData.init() I call the M.loadAchievementListener(), this function:

function M.loadAchievementListener() gameNetwork.request("loadAchievementsDescription", {listener = M.loadAchievements}) end

The callBack function loadAchievements is this:

function M.loadAchievements(event) print("requestCallback") for i=1, 12 do if (event.data[i].isCompleted == true) then trophies[i] = true end end print("updatingTrophies") M.updateTrophies() loadsave.saveTable(trophies,"trophies.json") end

I even added some text to appear when this function is called but it does nothing.

Thanks once again

Hmm… hard to say looking at the snippets of code, but if M.loadAchievements is not outputting your print statements, then M.loadAchievementListener is not being called.

At this point, I would try to simplify to be sure everything is working and to narrow down the cause… place your init, login, and listener inside of main.lua. If that works, then there is some sort of issue with your myData library.

I tried putting all of it in the main, but the function is still not being acessed…

Looking a bit more closely, I this this…

gameNetwork.request("loadAchievementsDescription", {listener = M.loadAchievements})

should be this…

gameNetwork.request("loadAchievementDescriptions", {listener = M.loadAchievements})

Yeah, thanks, what a silly error. But I changed it and still not working…

Hi @jose.castanheira2,

Please try testing with a localized function located directly in the module, not added to another table. So something like this:

[lua]

local function loadAchievements( event )

   print( “loadAchievements function is being called!” )

end

gameNetwork.request( “loadAchievementDescriptions”, { listener=loadAchievements } )

[/lua]

Then report back if this is working.

Brent

It worked on the main, but not on myData. Good enough, I guess!