local card = {x, y, w, h};
function card:new(o, x, y, w, h)
local o = o or {};
setmetatable(o, self);
self.__index = self;
self.x = x;
self.y = y;
self.w = w;
self.h = h;
return o;
end
How do i loop through objects created by this class?
There is no way to do this, unless you add some structure to explicitly track created objects in a table somewhere (probably with "weak" keys to allow them to be garbage collected).
It may be possible to traverse all local and global values to find tables that have __index value pointing to that card table, but it's unlikely to be practical.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With