lua-users home
lua-l archive

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


There *is* an undocumented function in lauxlib.h called luaL_findtable
which does something like what you describe; however, seeing as it is
undocumented, its use is discouraged.

If I were you, I'd write my own utility function to do it, perhaps even
using the source for luaL_findtable as a guide.

-Rob

On Mon, 4 Apr 2011 21:59:56 +0300
C++ RTMP Server <crtmpserver@gmail.com> wrote:

> Hi,
> 
> Suppose we have a table initialized in lua as follows:
> 
> A=
> {
> 	B=
> 	{
> 		C=
> 		{
> 			key="value",
> 		},
> 		another_key="another_value",
> 	},
> 	yet_another_key="yet_another_value"
> }
> 
> Now, I would like to access A.B.C.key or A.B.another_key
> 
> As far as I know this can be accomplished by doing
> lua_getglobal/lua_getfield. Is there any way of doing this in a
> simpler way? 
> 
> luaL_register already does writing in this manner. For example, we
> can do:
> 
> luaL_register(L,"my.complex.package.api",pAPI)
> 
> where pAPI is luaL_Reg *pAPI
> 
> Cheers
> ------
> Eugen-Andrei Gavriloaie
> Web: http://www.rtmpd.com
> 
> 

Attachment: signature.asc
Description: PGP signature