Monthly Archives: July 2011

LuaInterface – Lua in .NET – Now on NuGet

I found myself looking at Lua today and was disappointed there was no NuGet package. I did find a project which acts as a gateway between the .NET CLR and Lua called LuaInterface. I created a quick project to see how easy it was to leverage Lua in a .NET project. I was shocked at how easy it actually was which made me even more disappointed to know there was no NuGet presence!

I packaged up the DLLs for Lua 5.1 and LuaInterface 2 with a couple little tidbits (for now) to modernize (a bit) the use of Lua and published the package to the public NuGet feed. Most examples I found on the web were old, weak on OO and did not make use of modern language features.

I created a custom Attribute – LuaAccessible – which acts as a marker for methods you wish to make available for use within the Lua environment. It contains no code or properties of any kind though someone could subclass it and the Register method below should still work.

I also created a short extension method – RegisterMarkedMethodsOf – to the Lua object which takes an object parameter to scan for methods marked with the custom Attribute and registers them with that Lua instance using the method name.

Continue reading