lua-users home
lua-l archive

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


Michael,
 
Thank you for the quick response, I must have missed this one in my inbox.
This should do it, thank you!

Sent: Thursday, August 13, 2009 8:10 PM
Subject: Re: Table inside table

Bas,
 
I had a similar question a couple of days ago. Turns out, it's quite simple, actually, and obvious once you see it. Go to the list archive at http://lua-users.org/lists/lua-l/ and do a search on  "multi-dimensional table".
 
Michael
----- Original Message -----
Sent: Thursday, August 13, 2009 10:59 AM
Subject: Table inside table

Hey everyone, I'm quite new to PBapi for Lua (structure is the same as in the C api)
I've been struggling for ages to push a table on the stack and fill it with data... this is what i've got
 
lua_newtable(*lua)
 
lua_pushstring(*lua, "NodeName")
lua_pushstring(*lua, "Nodevalue")
lua_settable(*lua, -3)
 
So inserting strings, booleans and numbers into a nummerically index, or name indexed table is getting along nice.
But now I'd like to insert a table in a node, and I'm completely lost here.
 
This is the Purebasic syntax
 
ProcedureC Somefunction(*lua)
    lua_newtable(*lua)
    For i=1 to 20
        lua_pushnumber(*lua, i)
        lua_pushstring(*lua, "Nodevalue")
        lua_settable(*lua, -3)
    next
EndProcedure
 
Instead of pushing a string, i'd like to push a table in that index. How would I do that? (even the filling must be done in that moment)
 
Thanks,
Bas


__________ NOD32 4333 (20090813) Informatie __________

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl