Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 languages (again!)  (Read 9710 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2007-07-16 12:24:52 »

I'm expanding Rescue Squad and one of the things I'd like to have is more interesting and varied levels which change on the fly (things going wrong, changing objectives, etc.). The obvious method would be some kind of simple scripting support, so I'm looking into which existing languages to use.

Searching through the forums, the main choices seem to be Beanshell, Groovy, Pnuts and Jython. Beanshell would be an obvious choice, as I wouldn't have to waste time learning a new language and the amount of work required to intergrate it and expose an API to it seems minimal. However *every* reference to it in the forum search seems to be people complaining about it's poor performance, which kind of puts me off somewhat.

Ideally I'd like a "simpler" language to script in (ie. less boilerplate code, less strict typing, etc.), so Jython would seem to be a good option, but I suspect that would require quite a bit of more work to intergrate and manully expose a suitable API to the scripting language.

Since I'd like to stick to 1.4, anything that requires the new scripting stuff in the JRE is probably not suitable either. Anyone any recommendations before I just randomly pick one?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline SluX

Junior Devvie





« Reply #1 - Posted 2007-07-16 14:18:45 »

Well, i guess that all ur script calls are going to be driven by some events, and will not occur always in main loop iterations, i guess that beanshell would do the job-it did for me anyways....

"Intelligence is the most beautiful gift and the greatest temptation which one life can receive from the gods."Me Cheesy
Play strategic football
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #2 - Posted 2007-07-20 10:37:28 »

Bump, there must be some people with ideas about this. Wheres the obligitory post by oNyx that beanshell is slower than a dead snail? Wink

Currently, I'm leaning towards Jython, since the Python language is (IMHO) quite neat and has minimal boilerplate required for a basic script. However I still havn't actually started trying to intergrate it and get it hooked up to the rest of the game proper.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #3 - Posted 2007-07-20 11:13:22 »

Heh. Well, Beanshell is... ehm... not so cool, if you want to use something overly fancy like... loops. Wink

The big downside of Jython is the indexing, which happens on the first run. This can take a couple of minutes on slow machines. Quite the show stopper imo.

I think I would either give Pnuts or Groovy a whirl.

Janino would be also an option. The the scripts can be compiled on level load (don't worry... it's fast) and then evaluated (=executed) as often as you like at full speed.

Well, if you really want to get rid of strong typing you could also try Rhino (JS).

弾幕 ☆ @mahonnaiseblog
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2007-07-20 11:29:19 »

Uh, indexing? I've not heard anything about that. Got a link?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #5 - Posted 2007-07-20 11:50:18 »

Well, maybe it doesn't do that anymore. Feel free to give it a try.

Ah... found it:
http://wiki.python.org/jython/PackageScanning

弾幕 ☆ @mahonnaiseblog
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #6 - Posted 2007-07-20 12:21:47 »

Hmm... interesting, I'll have to keep an eye out for that.

Although the worst case is that if it's too slow to be acceptable I could always disable package scanning and make sure to reference everything by absolute class name. I was already planning on appending a set of standard imports to every script when loaded, so this would just be an extension of that.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Simeon

Senior Newbie





« Reply #7 - Posted 2007-08-04 17:00:03 »

What about Lua? It's a programming/scripting language which is used by quite a few games and applications.

Offline CommanderKeith
« Reply #8 - Posted 2007-08-06 07:26:07 »

I haven't used BeanShell in a game but I can say that it is not slow when the API's you are accessing are real java classes (not beanshell code) and these parts of the code will run as fast as any java code.  BeanShell code itself is slow because it is executed through reflection (java.lang.reflect).

Since the rendering code in a game usually takes the most time, and you're only using BeanShell to make maps, it probably won't be an issue.

One thing that's annoying about BeanShell is that it's not exactly like Java code and it's annoying when things don't work as they should, such as nested classes and anonymous classes which are buggy.  I'm sure that all of the scripting languages have things like this though, and none have been arounf as long as BeanShell that I know of.  I think it's a real pity that Sun haven't picked it up - it's so obvious that we should have an exact java-syntax scripting language...

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 848
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2007-08-11 15:26:19 »

What would be the difference between the java-language and an exact java-syntax scripting language?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline keldon85

Senior Devvie


Medals: 1



« Reply #10 - Posted 2007-08-11 16:53:51 »

What would be the difference between the java-language and an exact java-syntax scripting language?
A script doesn't need Java recompilation whereas Java code does. Plus it can make for easier development of simple behaviour, such as RPG scripts.

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #11 - Posted 2007-08-11 19:03:12 »

What would be the difference between the java-language and an exact java-syntax scripting language?

1. higher turn-over rates (especially on slow machines)
2. user can script without the hefty tools.jar bloat (~200kb vs ~6mb)
3. scripts can be compiled the usual way at the end for more speed and a smaller download
4. there is no new language to learn

For me it's 1+3 and a variation of 4 - I simply like Java (and I already know enough languages). I prefer strong typed languages and C-like syntax. And I really love Java's awesome documentation.

The number of keystrokes is the least interesting aspect of programming languages. Standardized code conventions for example have a far bigger impact on productivity.

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #12 - Posted 2007-08-14 18:34:59 »

What would be the difference between the java-language and an exact java-syntax scripting language?

When you're writing 100 unique combat variations for an RPG (you need a different combat snippet for each unique special effect and strange combination of super-abilities, like "unblockable") - obviously only overriding small parts of the combat each time! - and you have a couple of level-designers writing hundreds of different effects in each level .... well, you can easily save *months* of time just in not having to keep recompiling each script to see it work.

There's also the fact that scripts can be altered on the fly whilst hte engine is running and you've already setup a particular situation (e.g. run a particular level for 20 minutes to get to a situation you want to tweak). Eclipse can, obviously, do *some* hot-swapping of code, but tis not perfect, breaks on quite a lot of things, and requires you to be happy editing java source directly. Which means knowing the package structures etc.

malloc will be first against the wall when the revolution comes...
Offline tbulford

Senior Newbie


Medals: 1



« Reply #13 - Posted 2007-11-05 05:09:02 »

Everyone forgot Rino? LOL http://www.mozilla.org/rhino/ good thing about this option is that there are lots of skilled java script coders allready. Speed does seap fairly good.

We are using BSH though for 2 reasons. We dont run the BSH code often in the game so we can get away with slower. We create listner classes to various events to trigger things. As far as I know no other scripting language can do that.

Looking forward to the next version that promisses to pre compile the script to byte code.

--Travis

Offline fletchergames

Senior Devvie





« Reply #14 - Posted 2007-11-05 19:23:10 »

If you only need a few different commands, you might try just writing your own simple scripting language.  You might even do a "one line per command" language to avoid writing a real parser.

With your own language, you can precompile the scripts before they're needed.
Offline markus.borbely

Junior Devvie





« Reply #15 - Posted 2008-01-24 13:28:16 »

Even if this is an old thread, I feel I have to add my experience.

I used beanshell (with loops) to make my game: http://gunslinger-game.mine.nu/
It works great. Never any trouble.

But the game does relay on compiled code mostly. On every map there are from 2 to 8 statemachines running at various intervals (they have to tell when they want to run next before they exit).
This can do things like: "check if this has happend, advance the state and give the player a message". Typically from a few times each second to a few seconds between each run.

Also, some GameObject have event handlers that triggers on certain events. Like "onDeath", "onTouch" etc These  are not run that often.
Also, dialogs have conditions for certain lines and actions for lines.

This isn't an awful lot but sometimes I do pretty awesome things with it (the best is when an npc ends a dialog by shooting himself in the head (and is then beeing replaced by a corpse), or when you break open an artillery cannon to extract the grenade and rig it as a bomb that you can acutally use for a weapon).  Grin

Of course, all scripting languages will work for this. But beanshell is almost exactly like java. Very easy to integrate.
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.

Mr.CodeIt (6 views)
2014-12-27 04:03:04

TheDudeFromCI (12 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!