I'd recommend looking into a collision library like Bump which will let you have each entity type in its own table but still handle collisions between any entity anywhere. The only problem is it's a bit advanced.
So without bump I'll try to make it as simple as possible. Basically you need to loop over the same table for every item in that table by having nested for loops. Basically:
Code: Select all
for a, e1 in pairs(entityTable) do
for b, e2 in pairs(entityTable) do
if a ~= b then
-- Handle collision here
end
end
end