NLua 是 Lua 和 .NET 两个领域的连接枢纽。这个项目是由 LuaInterface (from Fábio Mascarenhas/Craig Presti) 改写的。
示例:
string script = @" local s = Scriptable (""My String Parameter"") s:DoSomething () print (s.Param1) local ret = s:SumOfLengths (""Name"", 10); print (tostring(ret)) Scriptable.Print(""Hello NLua"") s.Param3 = 0.5; local p2 = tostring(s.Param3) print (p2) "; using (Lua lua = new Lua ()) { lua.LoadCLRPackage (); lua.DoString (@" import ('NLuaSample') "); lua ["gValue"] = "This is a global value"; // You can set a global value. var returns = lua.DoString (script); Console.WriteLine (returns); }