lua-users home
lua-l archive

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


Why do you wish to do this? Perhaps there is a better way of accomplishing what you really want to do.

Also, in the case case your two states are really threads of a single global state, you can use lua_xmove() to move stack values between them.


On Fri, Dec 14, 2012 at 10:50 AM, Philipp Kraus <philipp.kraus@flashpixx.de> wrote:
Hello,

I'm using two different Lua states and I would like to copy a return argument of a Lua script function via C API into the other state eg:

--Lua script 1--

function test()
    return {1,2,3}
end

--Lua script 2--
   function test2( ... )
   end

On the first function the return argument can be changed, like return "test".
I would like to read the stack in C without any converting into C types:

lua_pcall( state1, ....)

std::vector<lua_types> l_data;
l_data.push_back( <put stack values from stat1>   );

push_to_stack( state2, l_data.last() );
lua_pcall( state2, ...)


I would get all return arguments in one structure independed of their types and push
them into another state

Can I read the return arguments into one memory block eg?

Thanks

Phil