The wiki says that:
http://www.love2d.org/wiki/World:rayCastYou cannot make any assumptions about the order of the callbacks.
However, I need to get these callbacks in a manner that allows me to make assumptions . Specifically, I'm tracing a ray for a bullet's trajectory, starting from the gun. As the bullet travels on it's path, for each entity it encounters, I need to check against a chance to hit. If a hit is registered, that entity loses health. If the bullet misses, we keep tracing.
The solution I'm thinking about is to fill in a table with each ray collision, sort the entries based on distance to the gun ( or maybe the "fraction" parameter from the callback? ) and go from there.
However, won't this break down when I cast more than one ray at a time? Or is each World:rayCast() call a blocking call (that is to say, for each ray trace, all callbacks will be made before the World:rayCast() call ends)?
PS: I'm new to Lua and not very certain of how multi-threading is handled.