lua-users home
lua-l archive

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

Hi there,

I am reading the docs over and over and I do not see how I am supposed to see if the userdata has it's own environment table...

I see that "userdata and C functions are created sharing the environment of the creating C function" and that "the environment of the running C function is always at pseudo-index LUA_ENVIRONINDEX".

So my guess is to do this:

// ... <userdata>
lua_getfenv(L, -1);
// ... <userdata> <env>
if (lua_rawequal(L, -1, LUA_ENVIRONINDEX) {
  // does not have it's own env table

Is this ok ?