JAVA as a scripting engine ?

Started by
6 comments, last by ahw 23 years, 1 month ago
I was reading this postmortem on Vampire Redemption by Nihilistic studios ... and they explain that they took JAVA and put it in their own game. Now the question I have is : How the heck did they get the source code of the Java Virtual MAchine and integrate that in their own software. Or is there a third party VM that I dont know of. Anyone ? youpla :-P
-----------------------------Sancte Isidore ora pro nobis !
Advertisement
Hey ahw,
I''m not sure how they used Java in their game... but, if your interested in embedding a scripting language into your game... I wouls suggest Python.

If you are interested in using Java as your scripting engine - I seem to remember an issue of Dr. Dobb''s Journal that had something showing how to do it. I remeber reading something on Gamasutra as well.


Game On,

Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
Check out the Q2Java page at http://planetquake.com/q2java. They made a dll to make Quake 2 mods in Java.

It''s me, it''s that T-H-E-D.
If you missed a great moment in history don't worry, it'll repeat itself.
It seems very hard to implemment a JAVA script engine in a game.
These day i try to make my own scripting engine ( C-like with Yack & lex) but Java can be better and maybe faster (and with less bugs).
_______________
Jester, studient programmerThe Jester Home in French
I''m not really sure what the problem is here...
There is a part of the JDK, or the standard Java library, called JNI, and it stands for Java Native Interface. Now, I''m not going to tell you about the inner workings of it, but please take time to read the following overview:

http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html

as for your VM question:
"The JNI allows Java code that runs within a Java Virtual Machine (VM) to operate with applications and libraries written in other languages, such as C, C++, and assembly. In addition, the Invocation API allows you to embed the Java Virtual Machine into your native applications. "

That should answer your question.

Combining the power of JNI, dynamic class loading, reflection etc, I''d say the possibilities are pretty much endless to what you can do. I know, I''ve done it myself on several occasions.

BTW, you guys just gave me a great idea there, writing a scripting engine in Java.....it''s so obvious!
Thanks!

Don''t hesitate to mail me if you have any questions about the abovementioned technologies.

// Mario

PS. If you are thinking about embedding a VM into your game/app/engine, make you pick one of the high-performance VM''s, like HotSpot.


"Use the force, read the source"
- Anonymous
"Use the force, read the source"- Anonymous
Just a follow up to my message... I stumbled onto this link whilst surfing codeguru.

This article shows you how to embed the JVM in your C++ code:
http://codeguru.earthweb.com/java/articles/216.shtml


Game On,


Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
this is not really a answer. more likely another question.
instead of building complicated scripts for you program, why not use a dymically linked library? (.DLL)
just leave some source-code in how to explain the programming structure, and then make a VERY easy scripting code to that.

Let me explain in this example.
let''s say i''m making an adventure game, and i want to make a new character.
now, i programmed my game to read a certain file for additional characters.
this file might look like this:

Edgin, Barbarian, EDGIN.DLL

the parameters in the file is: Name, proffesion, .DLL filename

now, the program will read the code in this file, as if it was a part of the original source code.

see? you''ve got the most powerful scripting tool (C++), and yet you''re not loosing any valuable computer-resources, trying to translate it!


TAKE NOTE!! this is only an idea i got. i''m not even close familiar to .DLL programming - i just know in general how it works - so i''m not even sure it''s practically managable.


Electron

"Who need more than 640kb of RAM?" -Bill gates -89


--Electron"The truth can be changed simply by the way you accept it.""'General failure trying to read from file' - who is General Failure, and why is he reading my file??"
It depend.
If you have too much programmer than a dll system is good.
But if you don''t have enough programmer, than i think make a scripting language and allow the scenarist to script what they want to add to their world.
In a big RPG-Game, i think, this is the best way.
_______________
Jester, studient programmerThe Jester Home in French

This topic is closed to new replies.

Advertisement