4 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 2
4 star 0
3 star 0
2 star 0
1 star 2
Compatible with
  • iOS
  • Android
  • Windows

NLua 1.3.2.6

Vinicius Jarina

Lua scripting for .NET.

NLua is the bind between Lua and .NET. It supports iOS, Android, Windows Phone 7/8.

Features

  • Easily eval expressions.
  • Call Lua from C#.
  • Call C# from Lua.
  • Use C# Objects, Properties, Methods from any assembly in your scripts.

For script eval, you can use DoString() or DoFile()


    using NLua;
    ...

    [Preserve (AllMembers = true)]
    public class Scriptable 
    {
         public Scriptable (string param)
         { // ... 
         }

         public void DoSomething ()
         {
             Console.WriteLine ("Do Something");
         }
    }

    void ExecuteScript ()
    {
        string luaFile = "script.lua";

        var lua = new Lua ();
        double val = (double)lua.DoString ("return math.sin (10)") [0];
        lua.DoFile (luaFile);
    }

    -- To create C# object from script, just call ClassName ()
    local s = Scriptable ("My String Parameter")

    -- To call methods use object:Method
    s:DoSomething ()

    -- To call static methods use ClassName.StaticMethod
    Scriptable.StaticMethod ('Param')

If you want to use your class from Lua you need to use [Preserve] to preserve your class, NLua will call the methods using Reflection. More info

Release Notes

NLua 1.3.2

  • Migration to unified Xamarin.iOS (iOS)
  • Added __call method to call Actions/Funcs from Lua as Lua functions.
  • Fixed #116 problem accessing base class method
  • Fixed #117 problem with same method in class and base class
  • Fixed #125 calling methods with params keyword.

NLua 1.3.1

  • Added support to WinRT (Windows Phone 8)
  • Added support to Unity3D
  • Update Lua 5.2.3 with latest patches
  • Fixed support to Unicode strings (UTF-8)
  • Fixed x86/x64 issue.
  • Fixed overload issue
  • Fixed support to Debug and DebugHook APIs
Write a Review

1 review

Shawn Lee rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Everytime I install this component, it seems to modify my xamarin.android.comm.targets file, and then my projects can not be compiled because invalid characters are found, my Xamarin IDE is Traditional Chinese language, The error message you can see as below:

I tried many times. Install this component, all projects can not be compiled, so I need to remove Xamarin IDE, then reinstall Xamarin IDE...install this component...all projects seems to be not compilable again...so I remove Xamarin IDE again.....repeat the procedure above forever.

So I can ensure the problem is the component, so if possible please check it in different language IDE.

Posted on: April 7, 2015 / Version: 1.3.2.6