10

Lately I am preparing myself to develop yet another game in XNA C#.

The last time I worked on a game in XNA C#, I ran into this problem of having to add maps and customizable data into the game. Each time I want to add in new content or change some values to the game character or something, I had to rebuild the whole game or what - which can take quite some time.

Is there any way which I can write gaming scripts to load the content that can be interpreted by my XNA C# game without having to compile? I am looking at hopefully Javascript.

I would hope that I can add in functions and other small API which can be called from the external gaming script to manipulate the game or load data so on. I am not concerned about the game being hacked since it's quite early yet - the development is of much priority.

Any help would be greatly appreciated.

mauris
  • 42,982
  • 15
  • 99
  • 131

3 Answers3

5

You can try Jint which is a open source Javascript interpreter written in C#

zfedoran
  • 2,986
  • 4
  • 22
  • 25
  • this looks like a very cool and easy idea. But how can I define pre-defined functions that can be called to run certain C# methods for example? – mauris Nov 28 '09 at 06:52
  • Ah ok I think Jint supports that as well, as written on http://jint.codeplex.com/wikipage?title=Quick%20Start&referringTitle=Documentation – mauris Nov 28 '09 at 06:53
  • Old question, I know, but this is exactly what I did just recently and it works really well, I was even able to create some debugging functionality. Here's some code (free to use ofc) : http://roy-t.nl/index.php/2012/06/05/using-javascript-as-a-script-engine-in-xnac/ – Roy T. Jun 11 '12 at 08:23
2

The compact framework doesn't include System.Reflection.Emit, which means you can't use IronPython. I recommend LUA, and you can find an XNA interpreter implementation with open source here

seraphym
  • 1,126
  • 1
  • 8
  • 21
  • it looks good. but I can't get it working on Visual C# 2008. The project seems to be very old. – mauris Nov 27 '09 at 08:09
  • If you don't want to mess with getting it to compile, he offers precompiled binaries - just add a reference in your game to the dll. – seraphym Nov 27 '09 at 19:16
1

Would IronPython be more appropriate? That should work well on "full" framework - but it looks like it might not work (yet) on xbox 360 (which uses compact framework).

For an IronPython / xna example, see here.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900