[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to return a table from a function
- From: Romulo Bahiense <romulo@...>
- Date: Mon, 07 Nov 2005 18:19:18 -0300
Return {sometable} ?
If you are willing to do it on the C side, then...
int myluafunction(luaState *L)
{
// Creates a new table on top of the stack
lua_newtable(L);
/* (Ab)use of it
lua_pushliteral(L, "bla");
lua_pushnumber(L, 1.0);
lua_settable(L, -3);
*/
// Tell LuaVM how many elements in the current stack you want
// to return to this function caller
return 1;
}
The Lua side...
local t = myluafunction() -- assuming this is the correct name
print(t)
> table: <some random characters ;)>
ps: Sorry for any bad C/English :)
--rb