On Mon, Dec 3, 2012 at 2:02 PM, Coda Highland <chighland@gmail.com> wrote:On Mon, Dec 3, 2012 at 1:56 PM, Philipp Kraus<philipp.kraus@flashpixx.de> wrote:Am 03.12.2012 um 22:44 schrieb Coda Highland:On Mon, Dec 3, 2012 at 1:47 PM, Philipp Kraus<philipp.kraus@flashpixx.de> wrote:Hello,I use lua_createtable for push std::vectors to my Lua function, it workswell.I would like to push also the std::map as key-value structure to Lua,so I have gotlua_createtable(m_lua, p_map.size(), 0);for( typename std::map<std::string, int>::const_iterator it = p_map.begin();it != p_map.end(); ++it ){lua_pushstring(m_lua, it->first.c_str());lua_pushnumber(m_lua, it->second);// should here a pop call on the stack?}// should here also a pop call on the stack?Which calls must be added, so I can use a table in the script, that has astructuretable["key"] = value ?In this case another question is occured: Can I used also a std::multimap?So can Lua handle tables withduplicated keys or must be the keys unique?ThanksPhilYou'd use lua_setfield() after those two pushes, and that'll pop themfor you, and Lua keys have to be unique. Check the docs for moredetails.Thanks, but how can I use the setfield with a map like std::map<int, std::String>.setfield need a char value.ThanksPhillua_settable if your key is a number./s/ Adam
Correction: if your key is a non-string, numbers aren't the only legal
non-string key type.