lua-users home
lua-l archive

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


Here is a piece of lua script:

a={some_key="some value...",some_other_key=233.2,"value without key"}

for k,v in pairs(a) do

Running this script will output:

number	1	value without key
string	some_other_key	233.2
string	some_key	some value...

Perfectly agree with that. But suppose I want to pass such a table as a parameter to a lua function from c++. How do I insert a value into a table without specifying the key from c++?

Normally I do:

lua_push... //key
lua_push... /value
lua_settable(L, -3);

But lua_settable is extracting 2 elements from the stack. What should I put instead of the first lua_push to obtain an auto assigned key?

Thank you