lua-users home
lua-l archive

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

> I have something like this in the stack (from bottom to top)
> { aTable, aFunction, aValue1, ... aValueN }
> What I want is to put aFunction below aTable.

If you want to exchange aTable and aFunction, there's a third way:
	lua_pushvalue(L, 1);
	lua_pushvalue(L, 2);
	lua_replace(L, 1);
	lua_replace(L, 2);
At least this avoids the data movemement implied by lua_insert.

In Lua 5.2 you'll be able to do this:
	lua_pushvalue(L, 1);
	lua_copy(L, 2, 1);
	lua_replace(L, 2);