コード例 #1
0
int EventDispatcherBinder::dispatchEvent(lua_State* L)
{
	StackChecker checker(L, "EventDispatcherBinder::dispatchEvent", 0);

	Binder binder(L);
	EventDispatcher* eventDispatcher = static_cast<EventDispatcher*>(binder.getInstance("EventDispatcher", 1));

	luaL_checktype(L, 2, LUA_TTABLE);
//	lua_getfield(L, 2, "type");
	lua_getfield(L, 2, "getType");
	lua_pushvalue(L, 2);
	lua_call(L, 1, 1);
	std::string event = luaL_checkstring(L, -1);
	lua_pop(L, 1);
	LuaEvent e = LuaEvent(LuaEvent::Type(event.c_str()));

    LuaApplication *application = (LuaApplication*)luaL_getdata(L);
    lua_State *mainL = application->getLuaState();

    lua_pushvalue(L, 2);    // push event to main thread
    if (mainL != L)
        lua_xmove(L, mainL, 1);

    eventDispatcher->dispatchEvent(&e);

    lua_pop(mainL, 1);      // pop event from main thread

	return 0;
}
コード例 #2
0
ファイル: ElunaEventMgr.cpp プロジェクト: ElevimRG/LuaEngine
void ElunaEventProcessor::AddEvent(int funcRef, uint32 delay, uint32 repeats)
{
    AddEvent(LuaEvent(funcRef, delay, repeats));
}