title: C++ Lua (table of table of objects)
body: <p>I want to convert a vector of vector of objects to a table of table of objects in Lua.</p>
  
  <p>So I have a simple script in lua :</p>
  
  <pre><code>objects = getObjects()
  explosion = objects[1][1]:getDestructible()
  print (explosion)
  </code></pre>
  
  <p>And this is my .cpp file</p>
  
  <pre><code>std::vector&lt;std::vector&lt;Area&gt; &gt; objects;
  int x;
  int y;
  
  y = 0;
  lua_newtable(L);
  for (std::vector&lt;std::vector&lt;Area&gt; &gt;::iterator it = objects.begin(); it != objects.end(); ++it)
  {
      lua_createtable(L, 2, 0);
      x = 0;
      for (std::vector&lt;Area&gt;::iterator it2 = it-&gt;begin(); it2 != it-&gt;end(); ++it2)
      {
          lua_newtable(L);
          luaL_getmetatable(L, "luaL_Object");
          lua_setmetatable(L, -2);
          lua_rawseti(L, -2, x + 1);
          x++;
      }
      lua_rawseti(L, -2, y);
      y++;
  }
  </code></pre>
  
  <p>When I run the script I always get something like "Attempt to index a nil index". Did I miss something ?</p>