lua-users home
lua-l archive

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


Thanks for the help. This is all working great for me now! What do weak 
tables mean? I saw that on the Lua 4.1 (possible) feature list.

Jules


In a message dated 4/18/01 5:49:12 PM, froese@gmx.de writes:

<< I assume you mean this kind of tables: { "foo", "bar" }

These are regular tables.  Only the keys are the numbers 1, 2, ...

lua_newtable(state);
lua_pushnumber(state, 1);
lua_pushnumber(state, lastworld->active);
lua_settable(state,-3);

or:

lua_newtable(state);
lua_pushnumber(state, lastworld->active);
lua_rawseti(state, -2, 1);  // the 1 is the numeric index

> 2) how I GET the values from a table passed in (both indexed and with
> properties)

Same as above:

lua_pushstring(state, "active");
lua_gettable(state, <tableindex>);

or

lua_pushnumber(state, 1);
lua_gettable(state, <tableindex>);

or

lua_rawgeti(state, <tableindex>, 1);  // get field nr 1

or iterate over all elements using lua_next().

Ciao, ET. >>