Adding scripting functionality to .NET applications

前端 未结 9 1364
不思量自难忘°
不思量自难忘° 2020-11-29 21:55

I have a little game written in C#. It uses a database as back-end. It\'s a trading card game, and I wanted to implement the function of the cards as a script.

What

相关标签:
9条回答
  • 2020-11-29 22:41

    If you don't want to use the DLR you can use Boo (which has an interpreter) or you could consider the Script.NET (S#) project on CodePlex. With the Boo solution you can choose between compiled scripts or using the interpreter, and Boo makes a nice scripting language, has a flexible syntax and an extensible language via its open compiler architecture. Script.NET looks nice too, though, and you could easily extend that language as well as its an open source project and uses a very friendly Compiler Generator (Irony.net).

    0 讨论(0)
  • 2020-11-29 22:42

    I'm using LuaInterface1.3 + Lua 5.0 for a NET 1.1 application.

    The issue with Boo is that every time you parse/compile/eval your code on the fly, it creates a set of boo classes so you will get memory leaks.

    Lua in the other hand, does not do that, so it's very very stable and works wonderful (I can pass objects from C# to Lua and backwards).

    So far I haven't put it in PROD yet, but seems very promising.

    I did have memory leaks issues in PROD using LuaInterface + Lua 5.0, therefore I used Lua 5.2 and linked directly into C# with DllImport. The memory leaks were inside the LuaInterface library.

    Lua 5.2: from http://luabinaries.sourceforge.net and http://sourceforge.net/projects/luabinaries/files/5.2/Windows%20Libraries/Dynamic/lua-5.2_Win32_dll7_lib.zip/download

    Once I did this, all my memory leaks were gone and the application was very stable.

    0 讨论(0)
  • 2020-11-29 22:47

    I'd suggest using LuaInterface as it has fully implemented Lua where it appears that Nua is not complete and likely does not implement some very useful functionality (coroutines, etc).

    If you want to use some of the outside prepacked Lua modules, I'd suggest using something along the lines of 1.5.x as opposed to the 2.x series that builds fully managed code and cannot expose the necessary C API.

    0 讨论(0)
提交回复
热议问题