lua-users home
lua-l archive

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


I sent a similar email yesterday bit it appears to have never made it to the list. Apologies this ends up getting posted twice.

I've got a Lua "class" which manages configuration information. It's a hierarchical set of tables, something like, so from Lua I can do
stuff like:

	config.install.location = "/home/user/myApp"

Like a registry kind of thing. I would like to be able to call into this "class" from C and ask for values, like

	const char* value = config->getValue("install.location");

If I have a Lua function that looks like this:

	function Registry:getValue(key)

is there a clever way to get the value referenced by the string 'key'? Intuitively what I want is:

	return self[key]

but self["install.location"] obviously doesn't work. I can parse out the '.' characters and step down the tree manually but that seems so...un-Lua.

Thanks for the help (again),
Jason