lua-users home
lua-l archive

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


Hello!

I have a C function that must return a table.
The table is a pure list, like this:

{
  "item1",
  "item2",
  "item3",
}

My doubt is if I must tell the table index when adding
the item, or there is another aproach?

The function is like this:

int thefunc(lua_State *L)
{
    lua_newtable(L);

    // check parameters ...

    for(int i = 1; i <= someValue; i++){

      ...
      
      lua_pushnumber(L,i); // the index
      lua_pushstring(L,someString);
      lua_settable(L,-3);
    }

    return 1;
}

Thanks!





	
	
		
_______________________________________________________ 
Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. http://br.acesso.yahoo.com/ - Internet rápida e grátis