[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] Mono LuaInterface
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 10 Jul 2012 09:48:54 +0200
This is a Mono-compatible version of LuaInterface , which is a
binding of Lua to .NET.
Since 1.5.3, LuaInterface moved to a fully managed solution, where the
Lua C code was compiled as CIL, which was more convenient for
deployment with .NET applications, since it then only required a
single assembly and no messing around with native DLLs. Another reason
is that much of the overhead of going between Lua and C# is due to
P/Invoke, not reflection. This is one of the conclusions of the
excellent article by Fabio Mascarenhas and Roberto 
This is however not the best solution for using LuaInterface for
general Lua scripting that needs to still be able to use existing Lua
binary modules, and was not an option for Mono, since gcc does not
have a standard CLI backend ,
The background behind this effort is a general effort to bring Lua to
the popular Unity3D game editor by Alexander Gladysh and his company
LogicEditor (http://logiceditor.com). and this effort has been made
possible by his generous support.
The repository is here  which is the latest LuaInterface 2.0.3
modified to using P/Invoke to load the native Lua shared library.
There have been some fixes to property/field lookup and error
The suggested way to get things running is via the old-fashioned
./configure && make && ./install. There are some installation notes
in the readme, but the key thing here is that you will need a Lua
shared library, the headers to compile the luanet.so stub and the Mono
BTW, it still works on Windows, using the MS csc compiler (and if you
have .NET on your machine, you have csc.exe, which is a rare case of
MS giving away goodies with their operating systems) This version is
much better suited for integration with Lua distributions, such as
LuaDist, and I will provide compatibility with that distribution in
due course. So this helps to complete the feature set of the original
Lua for Windows.
A nice example to show how to access Lua from C# code is here 
The cool thing about bindings to managed frameworks like Mono or Java,
is that you can easily access any libraries built for these platforms,
without having to write any extra binding code. So for instance, here
is _yet another way_ to use GTK+ from Lua:
local win = Window("Hello from GTK#")
local label = Label()
label.Text = "Hello World!"
(WinForms applications still run on Mono, but the aesthetics of the
result leave a lot to be desired.)
The worm in the apple is that some of the nicest features (like using
a Lua function as a delegate in this example) depend on run-time code
generation, and some popular platforms (like MonoTouch for iOS) don't
allow this. There are however workarounds for this issue.
Thanks to Alexander and LogicEditor for their support; they are true
friends of Open Source for funding an MIT licensed project.
steve d .
 However, there _is_ an experimental gcc backend: