Log In  
Follow
chidori
Follow

Hello,
I'm doing some Lua pseudo-OOP stuff, and I want to check if tables within a shared table are colliding.
I have a simple AABB check-collision function that takes the x, y, width, and height of two objects and returns true or false if they're intersecting or not.

I'm assuming I should loop through the main table like so

FOR K,V IN PAIRS(DUDES) DO
 IF CHECK_COLLISION(V.X,V.Y,V.W,V.H ... THEN
  DO_STUFF()
 END
END

I'm not sure how to reference a value of the next table from the same table. I've tried

 IF CHECK_COLLISION(V.X,V.Y,V.W,V.H,DUDES[K+1].X,DUDES[K+1].Y,DUDES[K+1].W,DUDES[K+1].H

and a few similar methods, but none of them seem to work. I think I'm headed in the wrong direction, but I can't figure it out. Do I need to do some nested looping to index each table DUDE within DUDES, or use a different method from pairs?

P#19419 2016-03-26 18:37 ( Edited 2016-03-27 00:17)

Follow Lexaloffle:        
Generated 2020-07-15 06:38 | 0.078s | 4194k | Q:10