[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Embedding lua - passing arrays, multidimensional arrays
- From: Ervin Hegedüs <airween@...>
- Date: Thu, 24 Sep 2015 13:40:15 +0200
Hi Dirk,
thansk for your answer,
On Thu, Sep 24, 2015 at 01:05:34PM +0200, Dirk Laurie wrote:
> 2015-09-24 11:21 GMT+02:00 Ervin Hegedüs <airween@gmail.com>:
> > Hi Lua-l list,
> >
> >
> > On Wed, Sep 23, 2015 at 10:35:21AM +0200, Michal Kottman wrote:
> >>
> >> Instead, take a look at Programming in Lua, especially
> >> http://www.lua.org/pil/24.2.html to learn about accessing Lua from C using
> >> the stack. The book is written for Lua 5.0, but still very relevant even
> >> with 5.3.
> >
> > so, I've read the documents above - that's very-very clear. Now I
> > think I understand the stack - it's not just very funny, it has
> > cold logic, and pure implementation.
[...]
>
> You are making life needlessly complicated. Many of the things
> you do don't need Lua values, C values are fine.
well, I just followed the documentations above... what is the
"official way", if that isn't? :)
> The main table is more easily populated with lua_seti.
As I see, the lua_seti() (and lua_geti()) was introduced in Lua
5.3 - but looks like that's "too fresh". There isn't any package
in my distro. Lua 5.2 is enough.
May be that's "complicated" (not), but the solution is clean.
> If you rewrite your Lua code as:
>
> > /*
> > myTable = {
> > [0] = { a = 4, b = 2 },
> > [1] = { a = 13, b = 37 }
> > } */
> >
>
> you can populate the subtables with lua_setfield.
right, thanks. I'll review the lua_setfield(), after the first
view, I've seen many other functions, eg. lua_creattable() (which
also doesn't exists in the docs, as example - that's no problem,
I just write this, because I'm learning it now...).
Thanks again,
a.
- References:
- Embedding lua - passing arrays, multidimensional arrays, Ervin Hegedüs
- Re: Embedding lua - passing arrays, multidimensional arrays, steve donovan
- Re: Embedding lua - passing arrays, multidimensional arrays, Ervin Hegedüs
- Re: Embedding lua - passing arrays, multidimensional arrays, Michal Kottman
- Re: Embedding lua - passing arrays, multidimensional arrays, Ervin Hegedüs
- Re: Embedding lua - passing arrays, multidimensional arrays, Dirk Laurie