moonsharp-devs / moonsharp

An interpreter for the Lua language, written entirely in C# for the .NET, Mono, Xamarin and Unity3D platforms, including handy remote debugger facilities.
http://www.moonsharp.org
Other
1.4k stars 214 forks source link

Unable to create instance of C# classes #208

Open xionglingfeng opened 6 years ago

xionglingfeng commented 6 years ago

Cannot create instance of C# class in Lua.

I looked at this discussion and use the following way to export a c# class:

UserData.RegisterType<Matrix<Int32>>();
script.Globals["Matrix"] = typeof(Matrix<Int32>);

However, it complains

> Matrix.__new()
stdin:(1,12-14): cannot access field __new of userdata<System.RuntimeType>

Is the syntax changed?

johmarjac commented 6 years ago

Any news on this?

oxysoft commented 6 years ago

Someone also had the same issue in this thread and the author replied, but didn't follow through with an update after. Would like some update on this as well because I am looking at using MoonSharp for our project and this is would be quite a moderate annoyance for the use cases we have.

johmarjac commented 6 years ago

MoonSharp is dead just like NLua... Guess I will go back to implementing my own script host with c# scripts.

oxysoft commented 6 years ago

I also arrived at a similar conclusion. The library probably still works fine but the last commit was 2 years ago which is not particularly comforting. Either way, after studying whether I should use C# or Lua for scripting I found out that using C# would be much more efficient anyway since I can leverage all the IDE power I normally use and I can integrate it with very little work.

viniciusjarina commented 5 years ago

@johmarjac the point is not being dead, I wish I could have time to work on NLua, but unfortunately I am not paid to maintain the project. But on this thanks given I am trying bumping the support to Lua 5.3