lua-users home
lua-l archive

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


Hi

I have been tryng to export my table into C, but so far all i get is 
null values..,
Please, take a look at this code :

[LUA]

myData ={"um","dois","tres","quatro"}

function test_table()

 myData.um = 0;
 myData.dois = 123;
 myData.tres = 64.5;
 myData.quatro = 10;
 do_it(myData);
end

[LUA]


[C]

static int do_it(lua_State *L)
{
  char *text;
  lua_getglobal(L, "myData");
  if (lua_istable(L, -1))
  {
   lua_pushstring(L, "dois");
   lua_gettable(L, -2); 
   int pf=lua_tonumber(L, 1);
   printf("do_it value :%d\n",pf);
  }
  return 1;
}

[C]

As you can see, i'm just tryng to read the second value in the table, 
but all i get is 0.
What am i doing wrong ?
thanks,


Bruno