lua-users home
lua-l archive

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


Well that was really easy, thank you Enrico!

If anyone cares, my mistake was assuming that variables assigned
inside the custom _ENV would be "globals" (i.e. retrievable with the C
API's lua_getglobal()). They are in fact fields of my custom _ENV
table (the sandbox_env table in the example I posted), retrievable in
C by first doing:
lua_getglobal(L, "sandbox_env");
then doing:
lua_getfield(L, -1, "my_variable");

This is very elegant as is the rest of Lua, thanks to everyone who
helped make such a nice language!