From: Dirk Laurie
2013/12/3 唐兆宁 <yuxiaichou@gmail.com>:
> My problem is: I want to push a table to lua stack,not by the index,but
> the
> key value,which means I want to push a C++ map to lua table.For
> example,if I
> have a map "a" -> 1, "b" -> 2, can I get a lua table {a=1, b=2}? I find
> the
> lua_newtable and lua_rawseti could not work in my situation,Is there a
> solution? BTW, I use lua4.0.
I can only give a 5.2 answer but this a very basic question.
Say you have already got your new empty table on the stack in register t.
Then one field at a time, push the value on the stack and lua_setfield it.