lua-users home
lua-l archive

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


--- In lua-l@y..., Steve Dekorte <steve@d...> wrote:
> 
> On Thursday, June 13, 2002, at 08:53  PM, goldomyer wrote:
> > I'm having a problem accesing lua tables (multi dimensional).  I 
can
> > access a simple table no problem but get nil accessing a table 
such
> > as this:
> >
> > t = {{f="f1", s="s1"}, {f="f2", s="s2"}}
> >
> > however accessing this type of table i have no problem:
> >
> > t = {f="f1", s="s1"}
> >
> > can anyone help or point me in the right direction.
> 
> How are you accessing it?
> 
> It seems to work for me:
> 
>  > t = {{f="f1", s="s1"}, {f="f2", s="s2"}}
>  > print(t[1])
> table: 0x1df40
>  > print(t[1].f)
> f1
>  > print(t[2].f)
> f2
> 
> Steve

Sorry maybe i  wasn't clear ... i'm having problem accesing it from 
my "c" program.  Here is my code snipit:

const char *LuaGetTable(char *item)
{
  lua_pushstring(S, item);
  lua_gettable(S, -2);
  if (lua_isstring(pLS, -1))
  {
    return lua_tostring(pLS, -1);
  }
  return 0;
}

.
.
.

  lua_getglobal(S, "t");
  if (lua_istable(S, -1))
  {
    do
    {
      printf("t.f = %s", LuaGetTable("f"));
      printf("t.s = %s", LuaGetTable("s"));
    } while (lua_isstring(S, -1));
  }



Thanks in advance.
joe