lua : Geekin in the 7 cities

Embedding Lua in C#

About a year ago I played around with Lua. I had a good bit of fun but it never really took off for me. As is the case so many times, I pretty much forgot about Lua. I’ve got one of those attention spans that supports moving on quickly. Recently though, Lua came back into focus. This time as an embedded scripting component in a C#/AutoCAD.NET API application that I’m working on. Extending the extension sounds crazy but there was a need for it, and LuaInterface made the job uber simple. LuaInterface allows you expose your C# methods and classes to Lua. You can also use Lua tables within C#. For the methods I want Lua to have access to, I attribute them with a custom attribute class. I use a method (got the idea here) that performs some reflection tricks and handles the Lua registration automatically. As an old friend of mine used to say, it’s killer diller.