I’ve always wanted to have a scripting language in Eressea, for all kinds of reasons. The GM tool could really do with a console, for example. And monsters could be scripted without having to change the C code every time. Eressea is really pretty backwards in terms of technology.

So today, I made the old C code C++-clean (added a lot of extern “C” around them), and made lua bindings with luabind and I’m exposing a subset of the region and unit classes to lua. First script (apart from Hello world) listed all the regions by name and coordinates, it’s not much, but it’s a start.

It was actually easier to write small C++ wrapper functions (especially a wrapper template for the Eressea linked lists) and then use luabind (which is a C++ library) than to export the C structures directly though lua’s API. I really like luabind. I found 2 small bugs while I was working on this, but if they haven’t been fixed already, I’m sure they will be soon. The iterator support is rather fresh, after all.

Advertisements