lua bindings for eressea

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s