public static RealStatePtr GetMainState(RealStatePtr L) { RealStatePtr ret = default(RealStatePtr); LuaAPI.xlua_pushasciistring(L, "xlua_main_thread"); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX); if (LuaAPI.lua_isthread(L, -1)) { ret = LuaAPI.lua_tothread(L, -1); } LuaAPI.lua_pop(L, 1); return(ret); }