Search Unity

MoonSharp - a Lua interpreter written in C#, focused on ease of use

Discussion in 'Scripting' started by Xanathar, Sep 30, 2014.

  1. Xanathar

    Xanathar

    Joined:
    Sep 30, 2014
    Posts:
    6
    Hi everyone and sorry for joining in for what's, after all, a bit of advertising :rolleyes:

    I'm writing an open source Lua interpreter directly in C#, focused on ease of use and integration and compatible with .NET 3.5 +, Mono 2.6 + and Unity.

    Compared to wrappers over native Lua, being directly written in C#, it trades some performance in raw execution, with a good performance bonus when calling C# functions from script which - I think - it's preferable.

    I released version 0.5.0 yesterday, and it includes most of the standard library (in practice, 99% of what you might need in Unity) and apart from known bugs in the implementation of the string library it should work pretty well. I'm still writing the documentation/tutorials, but what's there should be enough to kick-start anyone who might want to use it.

    In the long run I hope to add/complete a debugger solution with user interface in a separate application (or in a browser, to be decided) which would help debugging scripts - specially helpful for the unity where the screen would be busy displaying the game.

    In case you want to check it out: http://www.moonsharp.org
     
  2. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,039
    Might also want to mention that it's on Github and open sourced under the BSD license. Oh wait, I just did that. ;)
     
  3. Xanathar

    Xanathar

    Joined:
    Sep 30, 2014
    Posts:
    6
    You're right! Thanks! :D
     
  4. doctorseus

    doctorseus

    Joined:
    Feb 27, 2013
    Posts:
    12
    Great. Finally a reason to dig into Lua. Everything looks really clean and organized.
    Just for the start I tried to use it in a empty Unity project and it worked like promised. But I am searching for an Lua interpreter which is runnable in the Webplayer and later on on the WebGL platform and it seems that it does not run like it should if I build it for the Webplayer and try to run it in the Browser.
    I know that native plugins do not work with the Webplayer, but as far as I know .NET libraries work as long as they do not use restricted Classes and build are for 3.5? Any hint on that?
    Thanks for your work!
     
  5. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Admirable effort and a fantastic looking website. Keep it up!
     
  6. Xanathar

    Xanathar

    Joined:
    Sep 30, 2014
    Posts:
    6
    Hi thanks for the congrats!

    Regarding the webplayer/webgl thing, I'll try doing a test on my PC and see what's happening
     
  7. Xanathar

    Xanathar

    Joined:
    Sep 30, 2014
    Posts:
    6
    Fixed the problems with Unity WebPlayer, and ported the test suite to Unity. Tried it on desktop, webplayer and android and runs ok :)

    I'll release binaries soon (few days), but if you dare cloning the github repo, it's there, along with a Unity project to see how to get the thing started.
     
  8. doctorseus

    doctorseus

    Joined:
    Feb 27, 2013
    Posts:
    12
    Pulled the latest changes of the repo, had to fight with this package manager called NuGet, but it works like a charm now on the WebPlayer. Thank you!
    @NuGet, I only got the Build running on VS2013 after I deleted the Folders in "packages/" and VS re-downloaded them for me. Maybe it's just because I have wrong settings, but I wanted to let you know.
     
    Xanathar likes this.
  9. eedok

    eedok

    Joined:
    Sep 21, 2009
    Posts:
    194
    Do requires not work in Moonsharp or am I going about it wrong? Here's the sample I'm trying to get running that doesn't work: https://dl.dropboxusercontent.com/u/168938/Moonsharp Test.zip

    EDIT: figured it out, added these lines after Script script = new Script(); and it works:
    Code (csharp):
    1.  
    2.        UnityAssetsScriptLoader uas = new UnityAssetsScriptLoader();
    3.         uas.ModulePaths = new string[1];
    4.         uas.ModulePaths[0] = UnityAssetsScriptLoader.DEFAULT_PATH + "/?";
    5.         script.Options.ScriptLoader = uas;
    6.  
     
    Last edited: Apr 10, 2015
  10. biyyalakamal

    biyyalakamal

    Joined:
    May 8, 2013
    Posts:
    1
    HI,
    I am trying use lua script files.
    I tried to make the webgl build. but it is getting error.
    But if i switch platfrom standalone , it is working good. but i want run webgl .
     

    Attached Files:

  11. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,187