XNA Game Engine with (C# + Jint)

Jan 3, 2010 at 9:16 PM

Hi. I was directed by Nocilas Penin (he's one of the Jint Developers?) to this forum to find out more about how I could integrate Jint into a XNA Game Engine (with a 3D Scene Editor).

Ive never worked with Jint or any script languages before (although I know Java).

I would like to be able to add functionality to the 3D scenes using Jint. Any tips on the way to do this?

Thanks

Q

Jan 3, 2010 at 10:10 PM

Ive been told that I can do this:

JintEngine engine=new JintEngine().SetParameter("game",yourGameObject)

... after this - will I be able to call "game"'s methods or access its variables? If so how?

Thanks

Q

Jan 4, 2010 at 8:33 AM
Edited Jan 4, 2010 at 8:34 AM

Hi,

As I told you on stackoverflow, there are two ways to do so. It depends on what should be "scriptable", and how will be able to script it. If it is only you, then you can do it using 

JintEngine engine=new JintEngine().SetParameter("game",yourGameObject);

Then you can run script with the Run method. As Jint Name is explicit, the language is javascript. Here is a sample considering that you have a Scenes property on you game object, and that a Scene has an Animate method :

engine.Run(@"game.Scenes[0].Animate()");

Briefly, you can call methods of .NET objects as if you were .NET, but with the javascript language.

 

 

Nicolas Penin

Jan 4, 2010 at 3:55 PM

Thanks again Nicolas. Much appreciated for your patience.