How does one go about implementing a scripting engine (I'm thinking Jython) into Java?
I've never done this before, so one major question that I have is; how does the scripting engine know what function calls or fields are available to it?
Is there a simple tutorial to follow on implementing jython into a game? A book possibly?
-
1Found my answer at Jython documentation, and the integration is seemless! Very amused by this!orkel– orkel2011年05月12日 19:54:36 +00:00Commented May 12, 2011 at 19:54
-
Would you be so kind and help the community (and future googlers) by providing a brief explanation as an answer?Grzegorz Oledzki– Grzegorz Oledzki2011年05月22日 20:15:49 +00:00Commented May 22, 2011 at 20:15
-
. could you please let us know how can this be done ..crackerplace– crackerplace2011年06月21日 07:20:09 +00:00Commented Jun 21, 2011 at 7:20
2 Answers 2
If you have jython.jar in your path you can start a PythonInterpreter, which can execute and compile strings and files and from which you can get python objects (Strings, Integers, Objects, Functions).
Comments
I created a Java interface and implemented that java interface using python. That way when you get the python class back as a java instance you can type cast it to the interface and know what methods are available. __call__ and __tojava__ are the jython methods to get an instance back from a python implementation.
The Jython Book has a pretty good example and tutorial on how to do this.