Use of Scripting Languages ?

I have heard time and again that scripting languages can be used to quickly speed up the development process for a game.

Using scripting languages we don’t have to build the whole game from scratch every time we make a small change. and it can also help with keeping different parts of the game like the logic from the main engine etc. separate

So can anyone tell me :

  1. What exactly are the uses of a Script
  2. How can I use scripts in my java game for the logic part or other things … (a Guide or Tutorial regarding this would be great)

Thanks a lot guys :slight_smile:

I don’t think scripts are necessary for a small pie project.

If you have 10 or 20 developers then yes, perhaps.

If you’re 1 or 2 guys, I’d just make a Java class.

Yeah, I wouldn’t bother. Even for a largish project, building it is literally as fast as saving the current file you’re editing, provided you’re using a decent IDE.

About the only time it makes sense, IMO, is if you’re trying to make some functionality moddable.

I did a cool thing in an RPG where each level file had a class file generated too from some Java code you could write into the level editor. Then you just use javac and, voila, you’ve accomplished what a lot of people use scripts to do.

Is there a way to compile Java source like that in an applet without breaking out of the sandbox?

how did you do that ? That is exactly what I am trying to achieve :slight_smile:

You are supposed to be able to use the javax.tools package. But ToolProvider.getSystemJavaCompiler() keeps returning null for me. Anyone know how to fix that?

The java tools are not part of the JRE but of the JDK, so you will be out of luck for this approach on the client side (you are not allowed to bundle the JDK or JDK classes with your game). I think Eli used this on his development-system, so he simply can execute javac or start an ant buildscript on the commandline (using the java.lang.Runtime class).

If you really need this (which I doubt) on the client side, the best bet would probably be using janino.

I’ve been using Janino for a bit. It’s great, except for an issue I ran into a couple of weeks ago - it doesn’t seem doesn’t seem to handle break and continue! It compiles the source using those just fine, but then fails on next compilation unit. Kind of a bummer, because it’s so good otherwise.

I personally only find myself utilizing scripts (and usually only for plug-ins built alongside an API of mine) when I’m wanting other people to contribute to parts of the game’s development…people that are less experienced with Java.

Scripts are overall just a waste of environment building time if you’re going to develop by yourself.

Develop something without any scripts first, then introduce scripts where it makes sense.

Your java may haven’t set in the classpath. some IDE can detect java folder by themself but if you try it on cmd prompt, javac can’t work.

LOL no wonder other people had trouble running it! XD I didn’t even think of that - this game obviously never made it to prime time. :smiley:

I have heard time and again that scripting languages can be used to
quickly speed up the development process for a game.

Essentially, that’s true. But strictly speaking, this actually isn’t limited to scripting languages. Replacing old code with new code on-the-fly can be even done with C or plain Java.

What exactly are the uses of a Script[?]

Generally speaking, any kind of “cold” code (i.e. code which gets executed rarely and which isn’t processing intensive) can be replaced with scripts.

Scripting in games is often used for some sort of hybrid which is somewhere between configuration and code. Basically, it’s some configuration with logic thrown in. E.g. there are conditions here and there and arrays/dictionaries and some loops to keep things DRY (don’t repeat yourself -> less repetitive) and maintainable.

E.g. if this weapon (a shotgun) is fired, there shall be 12 randomized projectiles each one got a knockback of 5, this particular sound file should be played, this animation is triggered, and the next shot can be fired in 500 msec.

Or things like UI, HUD/overlays, menu transitions, etc.

There are many AAA games which use Lua for this kind of thing.