
LuaInterface: Scripting CLR objects with Lua
Overview
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):
require("luanet") 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.Controls:Add(buttonOk) mainForm.Controls:Add(buttonCancel) mainForm.StartPosition = luanet.System.Windows.Forms.FormStartPosition.CenterScreen function handleMouseUp(sender,args) print(sender:ToString() .. " MouseUp!") end handlerUp = buttonOk.MouseUp:Add(handleMouseUp) handlerClick = buttonCancel.Click:Add(os.exit) mainForm:ShowDialog()
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.
Download
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.
Feedback
Please send comments, suggestions or bug reports through the LuaForge page.