Recommended Posts

I'm creating a Lua based ScriptingEngine for our team's game project.
i'm using the code at http://www.lua.org/manual/5.1/manual.html#lua_next
as you can see the lua_tolstring()-function may not be called which includes the lua_tostring()-macro.
so is there any workaround to read string values out of a lua table?

0

Share this post

Link to post

Share on other sites

Alternatively, you could duplicate the object on the top of the stack using lua_pushvalue(L,/* index of key */) and then call lua_tolstring() on the duplicate. Just remember to pop it off to rebalance the stack.

Disclaimer: while I have some experience in manipulating tables in C, I do not claim to be anywhere near an expert. Read the documentation carefully.

0

Share this post

Link to post

Share on other sites

"Alternatively, you could duplicate the object on the top of the stack using lua_pushvalue(L,/* index of key */) and then call lua_tolstring() on the duplicate. Just remember to pop it off to rebalance the stack."

i tried it but nothing happens

and i do not just want to read the key. i want to get the value too. if its a string or not.