🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

AngelScript - C# Integration

Started by
5 comments, last by Trilogic 18 years, 6 months ago
I'm looking for a good Scripting engine to embed into C# projects of all sorts - mostly data shoveling and screen scraping apps (boring I know). I've been working in the arena of embedded scripting since Tcl 4.x so it's not a new topic, but it's been a while since the last project and embedded scripting has changed alot on the past few years - so much more to choose from. For my latest project I started with Lua and then moved to Squirrel for the OOPS of it. I am currently working on embedding Squirrel into C# (akin to the LuaInterface and borrowing much code from) and have it working pretty well. What I'm wondering is wether AngelScript would be a better fit for my purposes and if anyone has an embedding in a .NET project started, example, or? I'm wanting to be able to extend CLR based classes and use assemblies easily from within script. Thanks
Advertisement
For best performance, on .NET I would highly recommend using the built-in jscript/c# scripting facilities, since your scripts would be compiled to .NET bytecode, and run equally with the rest of your program. It is also very easy to embed, and no need for 3rd party libraries or files.

Using angelscript with .NET would require a fairly thick wrapper I believe, due the low level way functions are called (with AS managing the stack, based on the calling convention etc) ?
I would be very interested in seeing AngelScript working with C# applications, but I'm afraid that Tylon may be correct. AngelScript was designed first most to be embedded in C++ application, and may not have an adequate interface for .NET applications. It might be possible to use the AngelScript generic calling convention, which is similar to the way Lua allows applications to interact with the scripts, but I don't know if this is what you're looking for.

Why don't you use C# itself as your scripting language? AngelScript probably don't have any advantages over it. The syntax is also basically the same so that couldn't be the reason that you're looking at AngelScript.

This link, System.Reflection.Emit Namespace, may help in your effort to embed any scripting language with C#.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

On embedding JScript, C# or VB.Net: While these are indeed the more simple options to executing dynamic blocks of code I am not so sure that they are the best solution(s) to the problem.

CSharpScript is a very simplest way to perform the tasks to be sure - the project is nearly (if not) 100% complete and practically a drag-n-drop solution - but having control over the scripting runtime process adds another layer to the equation.

My reason for adding scripting is so that end users not only write scripts to control and extend the application, but also to allow the debugging of those same scripts. IMO that is a facet of embedded scripting that is most often overlooked.

Ahh, and here I thought AngelScript didn't have any advantages over scripting with C#. :)

AngelScript gives a lot of access to the internals of a script context. You can examine the values of local variables on the stack (as of version 2.5.0), you can set break points on script lines, or even special conditions. This is done by allowing the application to register a callback function that will be called for each script statement. When in the callback (or even from another thread) the application can choose to suspend the execution and continue at a later time.

Also, should you find that AngelScript is missing some important debugging feature please let me know and I'll see if I can include it.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Actually, DDJ has an large series on using the c# script interface and creating an complete scripting environment.

I've not read it completely, but it looks to be very powerful.
I like the prospect of having the callback and breakpoint capability. I'll begin the task of creating the managed wrapper. If I meet with success I'll post my results here and make the source available.

This topic is closed to new replies.

Advertisement