Hi,
So I’ve been trying to implement a login function on my C code and then I need to dispatch event along with some parameters.
This is my dispatch event code like :
// Create event and add message to it CoronaLuaNewEvent( L, kEvent ); lua\_pushstring( L, [sessionID UTF8String] ); lua\_setfield( L, -2, "sessionID" ); lua\_pushstring( L, [timeStamp UTF8String] ); lua\_setfield( L, -2, "timeStamp" ); lua\_pushstring( L, [mapID UTF8String] ); lua\_setfield( L, -2, "mapID" ); // Dispatch event to library's listener CoronaLuaDispatchEvent( L, library-\>GetListener(), 0 );
As you can see I’m trying to dispatch event with several properties : sessionID, timeStamp and mapID,
my lua code can receive the event but event.sessionID, event.timeStamp, etc always nil.
Is the code above the right way to add more properties in the event object? I can’t seem to find a good explanation on what lua_pushsting and lua_setfield do nor I understand where that -2 comes from.
Any help?
Thanks