lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> another method which I've not yet done but should work, is to 
> create a new thread, create a lua reference to it (using 
> lua_ref) then pop it off the stack immediately (so it doesn't 
> get buried), and later when you are done with it, destroy the 
> reference (lua_unref) and that should allow it to be GC'd 

	I dont know how to do and I just try like this:

	lua_State* m_L = lua_newthread(L);
	int refKey = luaL_ref(L, LUA_REGISTRYINDEX);

	NPC->L = L
	NPC->m_L = m_L
	NPC->refKey = refKey

		if (L)
			luaL_unref(L,LUA_REGISTRYINDEX,refKey );
	no error occur, but I wonder if it will work as I expect.