Search code examples
.netrubyscriptingxnaironruby

How to embed Ruby in an XNA engine?


I'm wondering if it's possible to embed Ruby as a scripting language in Microsoft XNA, and what's the best way to do that. I'm looking for something like Xnua, except for Ruby.

I've stumbled upon Ruby.NET and IronRuby and both seem to be in very early stages, so I'm not sure how usable they are. Furthermore, I'm not sure if they'd work on Xbox 360. This topic at XNA forums says that IronPython wouldn't work, for example.


Solution

  • IronRuby and IronPython do not work on the Xbox 360 because they are based on the DLR (Dynamic Language Runtime) and the DLR makes heavy use of System.Reflection.Emit types which are not currently available on the Xbox 360 .Net Framework (a modified version of the Compact .Net Framework).

    As to the best way to do that, unfortunately that depends on the rest of your game. The work to enable IronRuby scripts to be evaluated in the context of your XNA program is fairly easy, check out this blog post for example. Beyond that you'd want to expose some interesting objects to your scripts and that's the bit that's entirely down to the rest of your game code/design. You could have a look at the scripting docs for Unity to get an idea of what types and commands to expose.