lua-users home
lua-l archive

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


> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br 
> [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of 
> Shmuel Zeigerman
> Sent: Monday, August 27, 2007 6:27 PM
> To: Lua list
> Subject: Re: Passing arrays from C++ to LUA
> 
> > C++:
> >     lua_newtable (L);
> >     lua_settable (L,1);
> >     
> >     lua_Integer n = 6;
> >     lua_pushinteger (L, n);
> 
> Try something like this:
> 
> int arr[4] = { 5,100,-20,0 };
> lua_newtable(L);              // table
> for (i=0; i<4; i++) {
>    lua_pushinteger(L, i+1);    // table,key
>    lua_pushinteger(L, arr[i]); // table,key,value
>    lua_settable(L,-3);         // table
> }

Ok, this one works. But my error was another one. I use tolua++ as interface to LUA. But it has not all features I need. So I tried to get my data "through" tolua++. But it seems tolua++ hits me here. If I go into the generated binder code and change "return 0;" to "return 1;" it works. If I use "return 1;" to set the number of results before tolua++ gets the function tolua++ push the "1" onto the stack. But this isn't what I like. :-(

Do you understand the problem?
 
> ... and read "Programming in Lua" (http://www.lua.org/pil/),
> on-line and free :)

I'm reading this document. Very good!

regards
Andreas

--  
Dipl.-Inf. (FH) Andreas Volz, ES1
Elektrobit 
Phone: +49 (9131) 7701 167, mailto:Andreas.Volz@elektrobit.com
Fax: +49 (9131) 7701 333, http://www.elektrobit.com

Elektrobit Automotive GmbH, Am Wolfsmantel 46, 91058 Erlangen, Germany
Managing Director Otto Fößel
Register Court Fürth HRB 4886  


----------------------------------------------------------------
Please note: This e-mail may contain confidential information
intended solely for the addressee. If you have received this
e-mail in error, please do not disclose it to anyone, notify
the sender promptly, and delete the message from your system.
Thank you.