View previous topic - View next topic |
Author |
Message |
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Thu Jun 12, 2008 10:19 am Post subject: Java - Scripting? |
[quote] |
|
Java has the ability to load classes by runtime. So basically Java could be used as a scripting language for Java based projects.
But such "script" needs to be compiled with the project libraries, which most likely is out of the scope of the average mod developer?
I feel uncertain is I should use this concept, offering a "plugin" API for mod developers, to plug in their own code where the core project offers such interfaces, or rather use a traditional scripting language with is read from plain text files (without the compilation step)?
|
|
Back to top |
|
|
cowgod Wandering Minstrel
Joined: 22 Nov 2005 Posts: 114 Location: Pittsburgh, USA
|
Posted: Thu Jun 12, 2008 2:26 pm Post subject: |
[quote] |
|
It is my opinion that you should use a normal scripting language that reads text files.
I would not write scripts for the game if I had to compile them with some third party tool. If you created an editor that compiled the Java scripts automatically, that might work. Still, you should probably just use a normal scripting language.
If you write your own scripting language, you can set it up so that the script is compiled in some way when it gets loaded. Then the program will only need to parse it once.
The problem with writing your own scripting language is that people will have to read some kind of tutorial to use it, but most people would have to do that even if you used a common scripting language. An advantage of writing your own would be that it could do exactly what you need it to do, rather than whatever the developers' decided to make it capable of.
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Thu Jun 12, 2008 2:36 pm Post subject: |
[quote] |
|
A tutorial is need always, since the API of the projects core must be described somewhere.
I've been using Lua with my former project, that worked nicely, but the core was C++ there.
I think the Sun Java compiler is available and can be distributed with a project - so it'd be possible to read the Java source file and compile it during startup. But it still looks awkward to me.
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Fri Jun 13, 2008 3:06 am Post subject: |
[quote] |
|
Really depends on what you want to allow your users to do. Scripting tends to be more of writing instructions on controlling the flow of your program whereas plugins is like extending the features of your program such as adding an additional file format. I would include both.
If offering a plugin API, have you looked into SWIG? SWIG lets you expose your C/C++ interface to many different languages (python, php, lua, java, etc..) by simply writing one single interface file and having SWIG generate the underlying code to connect them together.
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Fri Jun 13, 2008 9:45 am Post subject: |
[quote] |
|
I'd like to stay away from too much C++ (or any language that is compiled to native code), since I want to keep portability high - if possible to all platforms where Java does run.
So text-based scripting language will be fine if there is an Java-based interpreter for them, or the other option is to extend Java by Java code.
The motivation for the question was to allow the mod-makers to alter the functionality of items, and more general to extend the stats of a PC with some that have module defined semantics. This really means to expand the engine with new functionality, therefore I think the word plugin is the best description.
E.g. such plugin will be able to implement functions like "onEquip", "onUnequip" triggered if a user equips an item, and then can implement the actions that shall happen upon these events, even if the engine core does not have the functionality.
Further functions will be "onUse" if an item is used, "onMove" whenever a PC moves and some more as they come to my mind. Just to give an idea what kind of plugin this is going to be.
|
|
Back to top |
|
|
valderman Mage
Joined: 29 Aug 2002 Posts: 334 Location: Gothenburg, Sweden
|
Posted: Fri Jun 13, 2008 11:37 pm Post subject: |
[quote] |
|
If portability is your goal, then you can use any of the more common scripting languages (Lua, Python, Perl, etc. - anyting FOSS) without a care. If you want to create your own language, well, write the interpreter in Java.
Personally, I'd say Java is overkill, even inappropriate, for a game scripting language. Way too much coding overhead to do even the simplest thing. _________________ http://www.weeaboo.se
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Sat Jun 14, 2008 12:12 am Post subject: |
[quote] |
|
I would find that adding functionality to items/equipment actions seems to be more of extending the functionality of the game which runs on your engine rather than extending your engine directly. I would think that scripting is bested suited for these case. I'd say LUA is pretty well suited for these kind of tasks.
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Mon Jun 16, 2008 2:19 pm Post subject: |
[quote] |
|
I feel uncertain which way to go. Portability in the Java sense means to provide one release which work on every platform (hopefully). Even if the scripting languages mentioned are portable by themself, they require different binary releases for different platforms - not a bad thing per se, but doesn't integrate as smoothly with Java as I'd like.
Since noone besides me is making mods/variants of the Sonnheim core game there isn't big pressure to answer this question. I think I'll prepare the interfaces in engine side as I can see a need or use for them, and decide later what will be plugged onto the interfaces.
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Tue Jun 17, 2008 12:05 am Post subject: |
[quote] |
|
I think I understand what you mean now. I had assumed that your project was not written in Java.
How about Jython, or JRuby? I know there's also Rhino if you want to support Javascript in your program. Scala seems popular as well.
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Tue Jun 17, 2008 2:09 pm Post subject: |
[quote] |
|
JRuby looks very nice and simple :) Thank you for the pointers! This will do the job and work very well with my core.
|
|
Back to top |
|
|
oenone Sick of Being A Fairy Princess Yet?
Joined: 17 Aug 2007 Posts: 14 Location: germany
|
Posted: Thu Jun 26, 2008 8:09 am Post subject: Re: Java - Scripting? |
[quote] |
|
Hajo wrote: | I feel uncertain is I should use this concept, offering a "plugin" API for mod developers, to plug in their own code where the core project offers such interfaces, or rather use a traditional scripting language with is read from plain text files (without the compilation step)? |
You could do both :-P
Provide a plugin API for Java and an interface for a scripting language. This way simple things could be done using the scripting language and if somebody wants to do bigger stuff, use the plugin API.
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Thu Jun 26, 2008 8:15 am Post subject: |
[quote] |
|
It's good that this can be split and done in two steps.
Currently I have a plugin API for the server-side, and I'm struggling with questions how to extend this to the client side code - I have a few options and try to figure out which is the best in terms of safety, complexity and usability.
Overall there is a distinct lack of options to have server code that asks the user for input ...
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Sat Jul 05, 2008 1:05 pm Post subject: |
[quote] |
|
I've used java as a scripting language on one project (this adventure game).
Basically, we had an engine written in C++ (with an old version Renderware as abstraction of the 3d hardware), and exposed C++ functions to Java. We integrated the java VM in the engine.
It worked quite well, and when we slipped towards the end of the project, and needed another scripter, we just got an experienced Java programmer who could hit the ground running.
All in all, I think it worked well. We could just as well have used another scripting language, but this was 8+ years ago, and there wasn't as much to choose from (lua was in version 3 somthing, I think, and not as mature as it is now).
If you're going to use a generic scripting language for your game, I don't think there's that much difference between using java, lua, python or other similar once. I'd probably go with Lua, as it is quite lightweight... _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Mon Jul 07, 2008 8:54 am Post subject: |
[quote] |
|
Currently I assume mod-makers will be people with at least some skill in programming. At least so much that they can take example plugin code and alter that. The most difficult step is to compile the altered plugin, but I think there are ways to call the Java compiler automatically, yet I haven't tried that.
So far the plugin idea works nicely, and there is no big pressure on better scripting support.
|
|
Back to top |
|
|