I’m trying to use data collected from getMatches() in a table and I just don’t get what I’m doing wrong. I’m pretty frustrated overall with cloud, since I haven’t gotten an answer to many questions I have, but I’m plugging away to try and get what I can to work.
[Lua]
lobbyUI = function ()
print(“lobby called”)
local matchTable = {} – Table I want to hold the results from getMatches
--EVENT LISTENER
function ccMatches( event )
if ( event.type == “Matches” ) then
print( “Get Matches successful” )
--event.results = table of values related to scores
local results = event.results
local maxMatches = #results
if ( maxMatches > 30 ) then maxMatches = 30 end --get maximum of 30 matches
for i = 1, maxMatches do
local matchID = results[i]._id
print(matchID) – Prints correct answer
end
matchTable = results – Already created matchTable above…
print(matchTable[1]._id) – correct
print(#matchTable) – correct
elseif ( event.type == “MatchCreated” ) then
print( “Create Match Successful” )
local results = event.results
end
end
Runtime:addEventListener( “Multiplayer”, ccMatches )
coronaCloud.getMatches()
– Got match results, which means that results should have been assigned to my table matchTable {}
print(“Testing”)
print(matchTable[1]._id) – Nothing
print(#matchTable) – error attempt to index field “a nil value”
[/Lua]
I don’t understand why matchTable is empty. It’s got to be a scope issue of some kind, but I don’t get why.
I’m probably doing something wrong that is obvious, let me know
I’m nearly ready to give up on cloud altogether at this point. I’m sure it will be worthwhile for some things once they are ready to support it, but I have not been able to get an answer for my primary question as to how to handle my game json files that are loaded and saved by players during their turns.
I’ve been able to make login/reg work and look good, I can load news, create/delete matches, create/delete chats, but that’s as far as I’ve been able to take it. All of which is meaningless if cloud won’t actually serve my multiplayer needs.
I went through the needed steps to get push notifications set up. I get told that device is registered in the simulator output, but when I try and send a push from the cloud console, it tells me there are no devices registered.
So, all together a bunch of issues that I can’t solve making me very frustrated. I just want to add multiplayer to my app… is that to much to ask for.
If can’t afford to waste much more time on cloud, which probably means I have to spend a bunch of time learning how to use pubnub and fork out what seems like a lot of money… I wish I had the knowledge needed to make noobhub work for me.