Log In  
Follow
chidori
[ :: Read More :: ]

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 2024-04-18 22:40:43 | 0.064s | Q:5