3

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.

5 Answers 5

8
+100

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.

2
  • Would Ruby.net work on Xbox360? My understanding is that it's not based on the DLR, but I'm not even sure if it's still under development. Mar 12, 2009 at 11:11
  • I don't know, but I wouldn't be surprised if Ruby.Net also made use of System.Reflection.Emit types. You could have a look at the source, just grepping for that namespace should tell you. Mar 13, 2009 at 17:42
2

It's almost guaranteed that IronRuby won't work on the Xbox, but if you just want to develop an XNA game for Windows, then you should be able to use it in the same way as for any other application.

I can't really tell you how you would go about doing that, just that it should be possible.

1
  • That's interesting. I'm still wondering if that also applies to Ruby.NET or any other interpreters I don't know about. Maybe try to write my own 'simple' .NET binding that'd work on Xbox? Oct 22, 2008 at 10:14
1

While I agree with Leaf Garland's observations, let me offer you an alternative:

The "preferred" scripting language for games is Lua. For example the game Crysis and Far Cry uses LUA extensively. Flick over at wikipedia for a list of notable games that uses it.

In terms of using that with XNA, i've only scratched the surface since I just started myself with hobby XNA development, but what I do know is that you cannot use LUA directly in XNA. This is because LUA is built in C++ (unmanaged) and therefore you will not be able to deploy that to your XBOX360.

There is a project under development that is building an XNA version of lua at http://www.xnua.com/. It is also a free product and the source code is also available for download.

If the gaming industry belives that LUA is good enough for AAA commercial games, I would personally follow that direction as well (on the basis that they have way way more experience in that area than I do)

2
  • I like Lua, but the question is pretty specific to Ruby because I already have a lot of Ruby code. The real answer is probably that it's not possible to embed ruby in XNA, but I still would like to see what other people think. Mar 12, 2009 at 11:09
  • 1
    eek! please do not use LUA as it does not mean the same as Lua
    – RCIX
    Jul 22, 2009 at 7:36
0

Why not use Ruby for PC development and Lua for 360?

EDIT: maybe this will be useful.

1
  • Because a lot of code has been already written in Ruby and I don't feel like rewriting all of it. Mar 12, 2009 at 11:06
0

Although it's not Ruby and this is an old question, I'd like to enlighten you to a new scripting engine I've been building. It will run basically anywhere there is a .Net framework, including on the Xbox360 under XNA. It does not make use of Reflection.Emit, so it works where other languages do not. It also is completely managed code, so no P/Invokes either like Lua.

You can get more information from my blog and can try it out at this demo page

It's almost ready for beta testing, but after beta testing it will be a commercially licensed component

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.