5.09.2005

generating wrapper code with tolua++

Posted by Luo Hei:

One of the biggest problems when you start scripting your game with Lua is creating all required code to access your host application variables from scripts and vice versa. Several utilities have been created to help dealing with such tasks. I haven't tested all them extensively, but I found that tolua and especially tolua++ fit my needs. The second is more oriented to C++ and they both work by using a package file with the data and functions you want to make available to scripts and generating a .h/.c file with the required C/C++ code. You only have to link the tolua lib and include a header file to have the extra functions required to push your variables or classes to the Lua stack.
A major drawback I find in tolua is that the documentation doesn´t cover clearly the C API.
The demo I include here maybe is a bit complex, but illustrates the integration of a C++ class with some scripts.
Have fun and suggestions/improvements are welcome.