Hello Corona Gurus,
This weekend I really buckled down and spent a good 8 hours seeing how involved an Amazon Game Circle plugin was. I have successfully implemented a great deal of the leaderboard functionality. I still have an outstanding question concerning the manifest, which I posted here. Additionally I have another question.
Presently I am able to return the current player score to the LUA module via a table. So the result you get in your LUA listener looks like this:
local msg
if (event.name == “get_your_score_from_leaderboard”) then
msg=“score:”…event.response.score…" rank:"…event.response.rank
native.showAlert( event.name, msg, { “OK” } )
end
I accomplish that with the following java dispatch event code:
final LuaState luaState = coronaRuntime.getLuaState();
CoronaLua.newEvent(luaState, eventType);
luaState.pushBoolean(false);
luaState.setField(-2, CoronaLuaEvent.ISERROR_KEY);
GetPlayerScoreResponse player = (GetPlayerScoreResponse) result;
luaState.newTable(0, 3);
int idx = luaState.getTop();
luaState.pushString(“local_player”);
luaState.setField(idx, “name”);
luaState.pushNumber(player.getScoreValue());
luaState.setField(idx, “score”);
luaState.pushNumber(player.getRank());
luaState.setField(idx, “rank”);
luaState.setField(-2, CoronaLuaEvent.RESPONSE_KEY);
CoronaLua.dispatchEvent(luaState, amazonGamesClientListener, 0);
But now I need to return an array of tables in event.response that represents the scores of multiple players. So instead of accessing the data in LUA as: event.response.score something more like: event.response.player[n].score (and of course an event.response.length).
I really don’t have a good idea how to make that happen. I’d appreciate any hints. Right now I have implemented the following plugin functions for Amazon’s GameCircle:
initialize(listener)
showLeaderboards()
postScoreToLeaderboard(leaderboardId, score)
getLocalPlayerScore(leaderboardId)
getAllPlayersScores(leaderboardId)
It’s the last call that I need to return the array of tables for. I have the data ready to go in the Java layer, just need to package it up and ship it off to LUA. My hope is next weekend to knock out achievements and then see if there is any interest from the folks at Corona of just adding the plugin to the general build so we can all use it from the Pro SDK. If not I guess I will have to convert my trial of the Enterprise edition to a paid version and then I will have to charge for the plugin to try and recoup some of my cash