문제

I have some C++ code that interacts with some Lua code. Basically, I want to be able to get some results (in the form of a dictionary a.k.a. a collection of items) from a query message and then push them out to Lua as a table so that I can easily access all the results from Lua by using the dictionary.

Right now, I just get one specific value that I want and send that out but it would be nice to send all of them out and not have to request a specific one.

도움이 되었습니까?

해결책

Assuming you're familiar with the Lua API in general, here's the basic process:

  1. Create a new table on the stack (lua_newtable)
  2. For each item in the dictionary
    1. Push the value onto the stack
    2. Push the key onto the stack
    3. Call lua_settable
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top