If so, could you provide an example of how? [import]uid: 21331 topic_id: 24284 reply_id: 324284[/import]
Sorry, I don’t have a good answer for you. I know all the core mechanisms to support table listeners are in the implementation of the Game Center APIs. But it’s not obvious to me how they would actually be used with the gameNetwork API. (I didn’t see any example in Papaya or OpenFeint either.) The way Corona uses them with other APIs which are more object based doesn’t mesh well with this more singleton like interface. Maybe you have some ideas?
I personally prefer closures anyway. Since closures are built into Lua, their behavior is very well defined/understandable/predictable.
[import]uid: 7563 topic_id: 24284 reply_id: 98681[/import]
Thank you so much for responding. The issue came as I was attempting to create a generic module for future re-use. Since the listeners did not have access to “self”, and subsequent variables owned by “self”, I was unable to achieve this in a clean manner. Such that:
gcLib = {}
local gameNetwork = require("gameNetwork")
function gcLib:NewGC()
local gcLib = {}
gcLib.gcLoggedIn = false
function gcInitCallback(event)
--This does not work as this is not a table listener
--if(self.gcLoggedIn == false) then
--Must be
if(gcLib.gcLoggedIn == false) then
end
end
function gcLib:InitGameCenter()
--This is ok, but cannot be used do to the fact that
--self.gcLoggedIn and gcLib.gcLoggedIn are not the same
--variable after gcLib is instantiated from an external
--call, and the listener needs access to the proper
--loggedIn state.
if(self.gcLoggedIn == false)then
gameNetwork.init("gamecenter", gcInitCallback)
end
return gcLib
end
I know I need to take the next plunge and start to use metatables more and REALLY get a solid grasp on the “inheritance” mechanisms used in LUA, but this general design has proved to be very easy to maintain and use for me…until GC. 
Any new light about this situation you can shed from a LUA angle would be greatly appreciated! [import]uid: 21331 topic_id: 24284 reply_id: 98743[/import]
Have you read this?
http://blog.anscamobile.com/2011/02/using-closures-in-lua-to-avoid-global-variables-for-callbacks/
[import]uid: 7563 topic_id: 24284 reply_id: 98794[/import]
Right… I use closures, just failed to think of its application here for some reason (probably due to GC kick’in my butt in general! :). I really appreciate the kick, I think when I get home I’ll be able to solve now. You rock and thanks for tak’in the time! [import]uid: 21331 topic_id: 24284 reply_id: 98801[/import]
Can’t thank you enough ewing, i needed that. You really come through every time!
< hat-tip > [import]uid: 21331 topic_id: 24284 reply_id: 98848[/import]