Accessing lua_state and fRuntime from delegates

Okay, So I am trying to make a callback for my plugin, it seems like fRuntime has expired.

Here it is:

VunglePlugin::DispatchEvent( char const \*event, bool isError ) const { lua\_State \*L = fRuntime.L; // ERROR ON THIS LINE: EXC\_BAD\_ACCESS CoronaLuaNewEvent( L, event ); lua\_pushstring( L, "Vungle" ); lua\_setfield( L, -2, CoronaEventProviderKey() ); lua\_pushboolean( L, isError ); lua\_setfield( L, -2, CoronaEventIsErrorKey() ); CoronaLuaDispatchEvent( L, fListener, 0 ); }

and my delegate:

@implementation VungleDelegate - (id) initWithInstance:(VunglePlugin\*)Instance { self = [super init]; if (self) { m\_handlerInstance = Instance; } return self; } -(void)vungleMoviePlayed:(VGPlayData\*)playData { NSLog( @"VUNGLE - vungleMoviePlayed" ); m\_handlerInstance-\>DispatchEvent( "vungleMoviePlayed", false ); } @end

Everything is fine until the line : lua_State *L = fRuntime.L; where it gives an error.

Does anyone know what i am doing wrong, or how else I can access lu_state.

Thanks!

Have you checked the common/basic pitfalls, e.g. how are you init’ing fRuntime?

BTW, you should have a call to “CoronaLuaGetContext( L )” somewhere. On iOS, this is what you would cast to id<CoronaRuntime> to get access to the runtime.

Oh, I figured it out. Thanks!

Have you checked the common/basic pitfalls, e.g. how are you init’ing fRuntime?

BTW, you should have a call to “CoronaLuaGetContext( L )” somewhere. On iOS, this is what you would cast to id<CoronaRuntime> to get access to the runtime.

Oh, I figured it out. Thanks!