Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Scripting inside of Java  (Read 1840 times)
0 Members and 1 Guest are viewing this topic.
Offline dray

Junior Newbie





« Posted 2007-07-26 23:40:33 »

I'm looking for some examples on how this done i.e Python or Jython.  It can be as simple as a Hello World example that has a greeting module to enhance Hello World to say Glad To See Ya.

Many thanks!
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2007-07-26 23:57:32 »

http://pnuts.org/~tomatsu/embedding.html

弾幕 ☆ @mahonnaiseblog
Offline beowulf03809

Junior Member




We live for the code, we die for the code


« Reply #2 - Posted 2007-07-27 15:42:30 »

That's a nice lin oNyx.  I like the way it compares the main options for some key tasks.

I am learning Jython at work for some stand-alone scripting needs ( always just worked in ksh before ) and in that process I've come across some embedding discussion over at the Jython site ( http://www.jython.org/docs/embedding.html ).  This actually looks to be an extension of the "Hello World" question from dray.

For me itt's not so much the technical "how" that has me looking for more info on this as the more nebulous "when and why".

In my virtually unlimited < wishful thinking > free time I've been supplementing my (fairly basic) J2EE Java experience to develop some games which are growing slowly in complexity.  I hope to start a basic turn-based strategy game soon and can understand how the use of scripting could help with many things including (if I understand correctly) the ability to tweak the game without need to recompile and re-run which would help speed up areas such as play balance tests, etc., as well as such things as scenario and map events.  However, I have not found a good reference of embedded scripts in action for such tasks.  Often things just click together for me once I see an example but trying to read and apply from a completely theoretical direction is harder.

I hate the situations of a solution looking for a problem and I am not yet at a point where I NEED embedded scripting, but if anyone can point to or explain some basic examples of a problem and how embedded scripting helped solve it I would appreciate it.

If this is going too far from the OP's question I can take it up in a different thread.  It seems it may be along the line of dray's question as well though.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #3 - Posted 2007-07-27 16:39:54 »

>[...]if anyone can point to or explain some basic examples of a problem and how embedded scripting helped
>solve it I would appreciate it.

You can use scripting for improving turn-over rates.

The usual cycle:
-observe
-exit the application
-change the code
-save
-compile
-start
-load media
repeat

With scripting:
-observe
-change the script
-save
-reload the script (eg by pressing F5 or whatever)
-load new media (if any) or force-reload media
repeat

Changing the code takes varying amounts of time, but the rest is sorta constant for a given project. On my really slow machine the former adds about 1-1.5 minutes of overhead, whereas the latter basically adds nothing. Saving takes a split second... reloading the script takes another split second.

It's sorta like writing html/css/js. You get instant results.

Btw I'm using Janino myself for the dev cycle (I script full classes) and I simply compile it the usual way at the end.

弾幕 ☆ @mahonnaiseblog
Offline cylab

JGO Ninja


Medals: 38



« Reply #4 - Posted 2007-07-27 17:20:59 »

I am also unsure about the benefits of scripting for java. If such "dynamic" functionality is needed, an application could provide a plugin-mechanism, that can automatically compile java-files in a plugin-directory and load them via a URLClassLoader.

Mathias - I Know What [you] Did Last Summer!
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2007-07-28 01:40:16 »

Yes, what I'm doing with Janino is pretty much the same... just a zillion times quicker.

Also if I would use it on the client side as well, I would only need the rather small janino.jar instead of that hefty tools.jar. Alternatively you could use jdt (the Eclipse compiler), but I didn't manage to get that one working.

弾幕 ☆ @mahonnaiseblog
Offline Mr_Light

Senior Member




shiny.


« Reply #6 - Posted 2007-07-28 03:34:09 »

I take it hot code swapping isn't doing it for ya then?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #7 - Posted 2007-07-28 18:34:22 »

Well, I do exactly that¹. But I'm using some ultra fast on-the-fly compiler, which is geared towards scripting.

[¹ With Janino that is. The system is pluggable and there are also loaders, which load classes directly or use Beanshell, Jython or whatever.]

弾幕 ☆ @mahonnaiseblog
Offline quixote_arg

Junior Member


Projects: 1


Jengibre


« Reply #8 - Posted 2007-07-28 19:13:30 »

If anyone is interested, I wrote a magazine article on java scripting using Java 6 scripting API

the catch is that it is in spanish, so only for spanish speakers Smiley
Offline shasheppard

Senior Newbie




Hopefully this works out.


« Reply #9 - Posted 2007-09-23 00:58:11 »

 entonces, donde esta la link carnal?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (14 views)
2014-08-01 22:53:16

CogWheelz (14 views)
2014-08-01 22:51:43

CopyableCougar4 (15 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!