lua-users home
lua-l archive

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

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

  /* (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
> table: <some random characters ;)>

ps: Sorry for any bad C/English :)