If you search through general Box2D help or tutorials, you’ll realize that there are references to many functions that are not available in the Moai. This is because everything we can access in Lua has to be exposed in the C++ source code, and they only did this for certain important functions. Some examples of missing functions are ray casting or getting a list of fixtures for a given body. Since Moai is open source, we can download the code, edit it and then have your own custom build that lets you access this extra functionality. However, this sounds like a lot of work, and there is an easier way.
Since getting a list of fixtures is conceptually pretty simple, we can actually implement it ourselves in Lua. Whenever someone calls the add* functions on MoaiBox2DBody (like addCircle() or addRect()), we want to keep track of the result and store it in a list. Then we need to create a new function getFixtureList() that returns this list. Using the same technique as I showed last time to override the dofile() function, we can override the add* calls to keep track of the fixture list. It looks something like this: