lua-users home
lua-l archive

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


Hello all,

I have a few questions:

Is there a way to determine what kind of index is being used in a table?
The reason I ask is because, while converting a vector3 implemented as a
table from lua to my c program, I run into situations where the index could
be numerical or a letter.  For example:

vector = {50, 50, 50}

would be converted to c using the line
    lua_pushobject(table); lua_pushnumber(1); variable.x =
lua_getnumber(lua_rawgettable());

If I create a table in lua where (for the sake of example... I have more
compelling reasons why this would happen in my own code)

vector = {x=50,y=50,z=50}

then it would be converted to c using the line
    lua_pushobject(table); lua_pushstring("x"); variable.x =
lua_getnumber(lua_rawgettable());

Is there a way to find out if an index is valid in a table?  I tested the
above, and lua_getnumber returns 0.0 if there isn't anything at that index.
Is there something like lua_isindex() ?

In addition, does lua_endblock() flush the c2lua stack?

Thanks!
Falko

PS Thanks to lhf for helping me with my previous posts.  Things are working
out really well.