lua-users home
lua-l archive

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


In my C program, I have multiple states. One of my functions check is if a lua reference struct I have (created with "luaL_ref") has the same state as another, and if not performs a "lua_xmove".

My problem becomes when my function is handed 2 independent "lua_State*"s that each came from their own "luaL_newstate()" (or similar) call. Is there anything about a specific "lua_State" I can use to find out if it's the top level state (not a thread)? Right now, what I'm doing is getting the main thread using a `LUA_RIDX_MAINTHREAD` call and seeing if it compares equal for both (then I know they came from the same state), but now I have to deal with Lua 5.1 and I don't have that capability.

I've seen the threads about storing the "main state" somewhere on that state: do I have any other options? Is there any way to tell if two "lua_State"s are disparate?