Enhancing game engine with scripting capabilities

Hello experts :slight_smile:

Maybe few of you remember me with my half-fail(or probably full-fail) game which I released like half year ago(or more). I have learned a lot from making it and was regaining forces during half year to start everything from scratch. Sorry for off top, going now directly to the questions.

I have started making new game engine and I want to enhance it with scripting capabilities. I want be able to use scripting on the map(for now adding new NPCs, objects and items, some map events) and NPC AI programming. I have already read some documentation of Groovy and Jyton, most likely to use Groovy, it appeared to me more attractive, unless some of you could give me advice using any other scripting language. This was the first question… The second question which I have is about embedding the script. The way I’m thinking to do this for the map for example is:
i) I create the map object with some tiles
ii) In separate file I create the script, which will have access to the map object, granted by embed mechanisms in my server code
iii) I place the script file only on the server and when some event occur I send the data to the client

Do I think correctly? Can you correct me and point the right way of doing this?
Thank you in advance,
ww

??? Well, despite that I’m going to jump in anyway … :slight_smile:

Another approach might be Janino - http://docs.codehaus.org/display/JANINO/Home but then maybe I’m too lazy to bother learning a new language just to get some dynamic coding. ;D I’ve been using it recently, and it seems to work really well - and of course, everything is as fast as the rest of your code.

I’m not too familiar with Groovy, but I am familiar with Jython. May I ask why do you think Groovy is more attractive that Jython? One advantage of Jython that I can think of is that Python is very popular among the developer community and if you use Jython, you can leverage a lot of existing developer resources that may or may not exist with Groovy.

Regarding the actual mechanism in embedding a interpreter into your engine, what I found is that once you have a scripting engine, the possibilities are limitless in terms of what you can do with external scripts vs. what you can do in your codebase. As long as you pass the relevant objects to your scripts, the scripts can take over the entire execution of your game if you like.

I created an experiment just to explore this possibility a while back, is it called whalechat and you can find it at http://whalechat.com. I have the vision of teaching computer programming using an online collaborative model within a 3D environment. When you launch the whalechat client, you can issue the “/editor” command which will bring up an editor for you to type in jython scripts, which is then uploaded to the server and executed in a shared environment.

The architecture that I went with is that I try to keep the core engine code as small as possible, with the engine focusing on the infrastructure stuff, and have the scripts handle all of the interaction logic etc. It works amazingly well and I managed to create a couple of mini-games inside the environment in this way. One such example is a little zombie game which you can access directly using the following URL:

http://whalechat.com/webstart.php?room=zombie

The script to the entire game can be found at http://whalechat.com/asset_server/rooms/zombie

Maybe this will give you some ideas on what is possible.

Hey

One the first things that come in favour of Groovy is it’s “proximity” to Java(including syntax), integration seems to be much easier then with Jython, at least this is what I read in some forum posts. I’m aware that Python is more stable and balanced. I have some experience with Python(I have already made Tetris game), but I really prefer Java, just a question of personal preference.

I already have imagined that potential of scripts is very high, but in large games it’s probably very hard to keep the codebase at the minimum, architecture must be planned very carefully and with several “heads”(people) (though this applies almost to all projects)

Thanks for you help and very demonstrative example. Bookmarked for future study :stuck_out_tongue:

Hi,

I do this using the built-in Rhino engine in Java6 (trying to keep dependencies down). I use it for menu code, puzzle code, maps and game interactions. Works great.