So I have a for loop:
for k, pt in pairs(points) do
self.centers[k] = Center:new() --<centers> is part of my Map object, and Center is an object
local bottomleft = Corner:new()
table.insert(self.centers[k].corners, bottomleft)
...--repeats 4 times for each corner of a square
end
There are 256 point in the list (points) and when I try to check how many values each center object has in the list (centers) it comes out as:
print(#self.centers[1].corners) --> 1024
I don't know why there are 4 times as many values in each of the (center.corners) lists when there should only be 4.
How do I fix this?
Edit:
function Center:new (o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
That is the Center:new() method