[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Copying one table into another (in C)
- From: David Dunham <david@...>
- Date: Wed, 15 Aug 2007 17:18:10 -0700
I'm in C, and want to copy all fields from one table into another
one. Sort of the moral equivalent of
for k,v in pairs(a) do b.k = v end
(which I don't think is correct in Lua).
It seems like lua_next would be the way to iterate the table and get
its keys and values -- it leaves them on the stack in such a way
everything is ready for a call to lua_settable. But that pops the
key, so that I can't then make the next lua_next call. (And I can't
just push the key an extra time after lua_next, because then
lua_settable wouldn't work.)
Am I missing something?
David Dunham Macintosh Game Developer
GameHouse Studios +1 206 926 5722 www.gamehouse.com
"They said it couldn't be done but sometimes it doesn't
work out that way." -- Casey Stengel