LuaInterface: Scripting CLR objects with Lua


LuaInterface is a library for bridging the Lua language and Microsoft .NET platform's Common Language Runtime (CLR). LuaInterface is a full consumer of the Common Language Specification (CLS), so Lua scripts can use LuaInterface to instantiate CLR objects, access their properties, call their methods, and even handle their events with Lua functions. Any CLR program can also use LuaInterface to run Lua scripts and modify the scripts' environment. This is a short, working example of LuaInterface in action (it shows a window, with two buttons, on the screen):

    Form = luanet.System.Windows.Forms.Form
    Button = luanet.System.Windows.Forms.Button
    Point = luanet.System.Drawing.Point
    mainForm = Form()
    buttonOk = Button()
    buttonCancel = Button()
    buttonOk.Text = "Ok"
    buttonCancel.Text = "Cancel"
    buttonOk.Location = Point(10,10)
    buttonCancel.Location = Point(buttonOk.Left, buttonOk.Height +
      buttonOk.Top + 10)
    mainForm.StartPosition = 
    function handleMouseUp(sender,args)
      print(sender:ToString() .. " MouseUp!")
    handlerUp = buttonOk.MouseUp:Add(handleMouseUp)
    handlerClick = buttonCancel.Click:Add(os.exit)

You can find more about LuaInterface by reading this paper, published in the proceedings of the 8th Brazilian Symposium on Programming Languages, or download the library and try it out.

Fabio Mascarenhas did the initial design and implementation of LuaInterface, and it is now being actively maintained by Kevin Hester.


LuaInterface is free software (MIT license), and can be downloaded from its LuaForge page. There are versions for Lua 5.1 and 5.0, and for use in versions 1.1 and 2.0 of the CLR.


Please send comments, suggestions or bug reports through the LuaForge page.