How to insert iron ruby ​​into a C # program?

I want to embed an iron ruby ​​in the mud that I create, and for some reason I am having trouble finding the right examples to start with.

All I want to do is create a game where the “you” player will program the bots in an iron ruby, and then I will iterate over the code in C # and force the bots to do what you want. In addition, I want to make it so that the code can be analyzed as a string in the form of an iron ruby ​​code, which I will use to control bots.

I understand that dlr and clr are two different things, but cannot find a pattern. The actual game is the classic telnet server, which I encoded in C # from scratch and connects via the strict telnet protocol.

It can be found here: pttmud.the-simmons.net: 4243 via the telnet client, and it should work.

+4
source share
3 answers

Take a look at this post: http://www.ironshay.com/post/make-your-application-extendable-using-the-dlr.aspx . It shows how to call IronRuby / IronPython code from C #.

+2
source

Not really Ruby, which below is what I am for IronPython (make sure the assemblies are listed first):

runtime = IronPython.Hosting.Python.CreateRuntime(); } public void Run(string script, params object[] variables) { var scriptSource = runtime.GetEngineByFileExtension("py").CreateScriptSourceFromString(script, SourceCodeKind.Statements); var scope = runtime.GetEngineByFileExtension("py").CreateScope(); foreach (var variable in variables) foreach (var property in variable.GetType().GetProperties()) if (property.CanRead) scope.SetVariable(property.Name, property.GetValue(variable, null)); scriptSource.Execute(scope); 

Here, the most important element is the script engine. You can request it with various options (extension in my case) and create scripts from memory or from disk sources.

You can also exchange variables that are also shown.

I think there is now a better way in C # 4.0, since C # itself has become a dynamic programming language.

0
source

Here is a complete example of how to run RSpec with C #.

http://gist.github.com/465677

Cucumber does not work.

0
source

All Articles