title: Lua: table element doesn't want to be copied while the value exists
body: <p>The key I'm assigning value to still remains nil after return!</p>
  
  <pre><code>p = {};
  for i = 0, 1000 do
      p[ i ] = {};
  end
  
  t = {}
  t.__index = t
  
  function new()
      local o = setmetatable({}, t)
  
  
      for key, value in pairs( p[1] ) do
          print(key .. " : " .. value)
          o[ key ] = value
      end
  
      t.__newindex = function(t, key, value)
          if type(value) ~= "function" then
            p[1][key] = value
          end
      end
  
  
      return o
  end
  
  local something = new()
  
  something.xxx = 666
  print(p[1].xxx)
  
  local something = new()
  print(something.xxx)
  print(p[1].xxx)
  </code></pre>
  
  <p>The problem is with it:</p>
  
  <pre><code>for key, value in pairs( p[1] ) do
      print(key .. " : " .. value)
      o[ key ] = value
  end
  </code></pre>
  
  <p>It shows xxx : 666 but o[ key ] still remains nil when I return it. The output is</p>
  
  <pre><code>666
  xxx : 666
  nil
  666
  </code></pre>
  
  <p>EDIT: yeah, I realized just now. I'll give you upvotes later because of net bandwidth(cant run stac with javascript) Thanks, now it works. Created new object based on previous one.</p>