lua-users home
lua-l archive

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


>It seems to me that that's wha you want to do, right?

Yes, that's pretty much exactly what I want to do.  Since I'm using 
Lua as a data description language, I often have lots of things where 
the C code wants to query a specific value that is global, e.g.:

//contrived but reasonably accurate example
float r = lua.getFloat( "/environment/ambient/color.red" );
float g = lua.getFloat( "/environment/ambient/color.green" );
float b = lua.getFloat( "/environment/ambient/color.blue" );

>You cannot get a table a in C. Instead of that you have to keep that
>reference inside lua, in a safe place like the registry. 

I may be using the wrong nomenclature here, but basically I don't 
want to "Get" the table, only to query a value in that table (or a 
subtable).

I thought that was basically how Lua4 worked, either that or I was 
using it completely incorrectly and it was broken in a manner that I 
expected =/  

This lack of documentation is a killer.  It's much better now than a 
year or two ago, but this is fairly trivial information that isn't 
documented anywhere, not even the lists (and the code isn't commented 
either).

Okay, enough ranting, I do like this language, really =)

>lua_pushstring(lua, "current_table");    // push key
>lua_pushvalue(lua, LUA_GLOBALSINDEX);    // push global table
>lua_settable(lua, LUA_REGISTRYINDEX);    // set key-value in the

>After that, when you want to get a value from your current table,
>you do:
>
>lua_pushstring(lua, "current_table");    // push key
>lua_gettable(lua, LUA_REGISTRYINDEX);    // get value

The above makes very little sense to me, since my preconceptions no 
longer seem valid with Lua5.

Is the registry just a mapping system of key to value globally?

Brian