482 Chapter 19 Other Programming Languages
19.5 Other Scripting Languages
Lua makes an excellent language for implementing game logic and anything beyond
the low-level routines used to run the game. At the risk of sounding like a stuck record,
the physics can be one of these low-level routines implemented in C++ and called
when needed from Lua.
Another option I’ve used, however, is to mix Lua into the physics engine. It is
relatively easy to expose Lua code as a force or torque generator into the physics engine
(this is particularly useful in my experience to create controllers for player characters).
To s e t t h i s u p, cr e a t e a
LuaForceGenerator in C++ that can call Lua code. The
RigidBody class will need its addForce and addTorque methods