Crashing plugin.

If I run this from a plugin and have a listener that catches eventName. In the function…

listener(event)

Can I call event.value and get the value I pass?

I think this is causing problems.

    private void sendEvent(String eventName, String eventText) {         Log.d("TEST", "Sending Event: " + eventName + " - " + eventText);                 try {             if (fListener != CoronaLua.REFNIL) {                 LuaState L = fParentRuntime.getLuaState();                              CoronaLua.newEvent(L, eventName);                 L.pushString(eventText);                 L.setField(-2, "value");                 CoronaLua.dispatchEvent(L, fListener, 0);                 Log.d("TEST", "Success, sent event!");                     } else {                 Log.d("TEST", "Success, but listener is null");                     }         });         catch (Exception ex) {             ex.printStackTrace();             Log.d("TEST", "Success, EXCEPTION during event call.");                 }     }  

Anyone have a working example on how to dispatch an event with data from the plugin back to the lua main app? I’m stuck on this.

I may be wrong, but do you need to set 

CoronaLua.dispatchEvent(L, fListener, 0);

to

CoronaLua.dispatchEvent(L, fListener, 1);

to say you are sending at least 1 return value?

public void sendEvent(String name, String value) { CoronaRuntimeTaskDispatcher dispatcher = new CoronaRuntimeTaskDispatcher(mLuaState); CoronaRuntimeTask task = new CoronaRuntimeTask() { @Override public void executeUsing(CoronaRuntime runtime) { LuaState luaState = runtime.getLuaState(); CoronaLua.newEvent(luaState, name); L.pushString(value); L.setField(-2, "asdfasdf"); try { CoronaLua.dispatchEvent(L, mListener, 0); } catch (Exception ex) { } } } dispatcher.send(task); }

Can you try something like the above.  You need the dispatcher to send the task.

I found out that it’s not the call that’s crashing it. It sends the event fine.

The problem is I’m triggering another runtime:event from inside this event and that causes the crashing.

Maybe I can send 2 events from the plugin? Instead of one from the plugin then one off the lua function?

Another crazy thing is that the original way works fine on all my devices but amazon tested this and it crashes on them Every time. :frowning:

Anyone have a working example on how to dispatch an event with data from the plugin back to the lua main app? I’m stuck on this.

I may be wrong, but do you need to set 

CoronaLua.dispatchEvent(L, fListener, 0);

to

CoronaLua.dispatchEvent(L, fListener, 1);

to say you are sending at least 1 return value?

public void sendEvent(String name, String value) { CoronaRuntimeTaskDispatcher dispatcher = new CoronaRuntimeTaskDispatcher(mLuaState); CoronaRuntimeTask task = new CoronaRuntimeTask() { @Override public void executeUsing(CoronaRuntime runtime) { LuaState luaState = runtime.getLuaState(); CoronaLua.newEvent(luaState, name); L.pushString(value); L.setField(-2, "asdfasdf"); try { CoronaLua.dispatchEvent(L, mListener, 0); } catch (Exception ex) { } } } dispatcher.send(task); }

Can you try something like the above.  You need the dispatcher to send the task.

I found out that it’s not the call that’s crashing it. It sends the event fine.

The problem is I’m triggering another runtime:event from inside this event and that causes the crashing.

Maybe I can send 2 events from the plugin? Instead of one from the plugin then one off the lua function?

Another crazy thing is that the original way works fine on all my devices but amazon tested this and it crashes on them Every time. :frowning: