   Lua with C++
  Let's say I have this Lua code:_G["Objects"] = {}function GetBase(str)local o = newproxy(true)local e = {Name = str, className = str, Parent = Objects}function e:remove()getmetatable(self).__index.Parent = nilendgetmetatable(o).__index = etable.insert(Objects, o)return oend_G["Instance"] = function(type)if type == "Quad" thenlocal New = GetBase(type)getmetatable(New).__index.Points = {x1 = 0, x2 = 0, y1 = 0, y2 = 0}return NewendendNewPart = Instance(Quad)NewPart.Points.x1 = 5NewPart.Points.x2 = 5NewPart.Points.y1 = 5NewPart.Points.y2 = 5I want to use C++ to get all the parts within the Objects table and get their Points values.  Any help, please.   
link;Quote:Original post by Matthew ShockleyLet's say I have this Lua code:_G["Objects"] = {}function GetBase(str)local o = newproxy(true)local e = {Name = str, className = str, Parent = Objects}function e:remove()getmetatable(self).__index.Parent = nilendgetmetatable(o).__index = etable.insert(Objects, o)return oend_G["Instance"] = function(type)if type == "Quad" thenlocal New = GetBase(type)getmetatable(New).__index.Points = {x1 = 0, x2 = 0, y1 = 0, y2 = 0}return NewendendNewPart = Instance(Quad)NewPart.Points.x1 = 5NewPart.Points.x2 = 5NewPart.Points.y1 = 5NewPart.Points.y2 = 5I want to use C++ to get all the parts within the Objects table and get their Points values.  Any help, please.First, your question: You have to use the Lua API. I can't think of the exact commands off the top off my head, but it would be basically get the table (lua_getglobal(L, "objects")) and then a loop to push indicies onto the stack, get values(lua_gettable(L, ?, ?)), and do whatever with them. As for how to get all the indicies, I don't know, I would refactor so that I could write it in Lua.More importantly, you are doing some wierd things in your code, and it looks wrong too.Here is my version of it (best guess for the worng parts).Objects = {}    --any reason to capitalize?function GetBase(str)   --this is global, same as Objects, is that what you want?    --first build e, (wtf is e, use descriptive var names)    --inconsistent caps here are you doing camelCase or FullCaps?    local e = {Name = str, className = str, Parent = Objects}    function e:remove()   -- cant't figure this out so i didn't fix   --you can't use getmeta unless you already gave the object a metatab   --what is this supposed to do anyway?   getmetatable(self).__index.Parent = nil    end    --you have to actually create a metatable    local o = setmetatable(newproxy(true), {__index = e})    Object[#Objects + 1] = o    --this is constant time instead of linear  --but it inserts at the end instead of begin    return oendfunction Instance(type)--Lua syntax is really nice like this    if type == "Quad" then --careful, type is shadowing a builtin func    local New = GetBase(type)    --does New already have a metatable? if not, you cant do this    --have to use setmetatable(New, {Points = ...}) instead    getmetatable(New).__index.Points = {x1 = 0, x2 = 0, y1 = 0, y2 = 0}    return New--had a superfluous end hereendNewPart = Instance(Quad)    --does quad exist?NewPart.Points.x1 = 5NewPart.Points.x2 = 5NewPart.Points.y1 = 5NewPart.Points.y2 = 5You don't seem to understand metatables. You shouldn't have to use them this much. read up on that and then try again. Also, your code had syntax errors, please at least make sure it works before posting (unless you post about it not working, which you didn't).I hope this helped, good luck!   ;  Metatables are quite easy, actually.  You don't understand that newproxy(true) returns a metatable with the type, "userdata".  You don't need to make a new metatable with one already created by newproxy(true).  Just use getmetatable on the newproxy(true) metatable and it works fine.   ;  It didn't have syntax errors either lol.  I did test it and it works fine.  I know Lua VERY well.  I just don't know the Lua API very well.   ;Quote:Original post by Matthew ShockleyMetatables are quite easy, actually.  You don't understand that newproxy(true) returns a metatable with the type, "userdata".  You don't need to make a new metatable with one already created by newproxy(true).  Just use getmetatable on the newproxy(true) metatable and it works fine.Ok I missed that the metatables were added by the constructor, it's just totally different from the way I do it (never mod the metatable outside the cons), so I got thrown off.As for syntax errors, you're right, it was correct. The indentation was wierd so I thought it looked like you had added en extra end when one was actually for the previous if. Yikes, and mine did have syntax errors, wow i feel like a jerk.I apologize for being a bit snappy, I shouldn't have assumed you were noob. Again, it was the indents that got me, did you intend to indent like that or did the forum mess it up? I suppose it would be more obvious with syntax highlighting.I'm still convinced that objects[#objects] = ... is better than table.insert(objects, ...).As for your original question, it looks like objects is just a list, so going from my handy-dandy Lua API reference, this might work:lua_getglobal(L, "objects");int n = lua_objlen(L, -1);for (int i = 1; i <= n; i++) {  lua_pushinteger(L, i);  lua_gettable(L, -2);  /*your object is on top of stack, do something with it. luaL_checkudata might help?*/  lua_settop(L, -2);}lua_settop(L, -2);Hopefully that works and allows me to redeem myself :)   ;  Its ok.  Thanks though.   