Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using Java and Jython, and after some research I discovered giving scripts direct access to the engine interface could be a mistake, as it would tightly couple the two.

It looks like most scripting that allows mods to create and manage entities does so through some sort of abstraction. Are these abstractions there for this reason, or is it just to provide a more intuitive way for non-programmers to mod the game?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

Both, in general. Your scripts should talk to an abstracted -- or at least intermediate -- layer of functionality and not the engine itself.

First, this provides you an extra measure of control and security. It allows you to easily, cleanly define the interface a script is allowed to have with your game and thus what it can muck about with, as well as allowing you to place extra security checks in the intermediate later that would not necessarily be appropriate in the actual functionality layer itself.

Second, it allows you to simplify the interface exposed to scripts to be more non-programmer friendly or easier to use in general.

It does provide a bit of insulation against coupling between the two, but it's often not that big a deal because the scripts will always be coupled to the interfaces they are allowed to interact with, by their very nature. The other two points are far more beneficial.

share|improve this answer

I also think that it helps you in case you want to make modifications to the engine. You can do them without worrying about having to change all of your scripts since the engine changed. You just have to change the abstraction layer Josh mentioned.

share|improve this answer

Creating a layer between the core of the game and the scripts, used for creating modifications is, in my opinion, necessary.

You gain several advantages by using this method:

Easier for modders:
A good reason to do this is, as you mentioned, an easier ways to make mods. Writing less lines of code means more readability and minimizes understanding issues for programming newbies. Ideally, this API should be a collection of methods to change something on the game's high level. This means for example: Spawn an entity without knowing how it really gets spawned, or displaying an image with one call, which only takes the image name as a parameter.
You, as a programmer, also benefit from it, as you can write more in less time than you would need with Java.

Security:
Preventing people from controlling the whole game is essential. I would not care, if the game would be a single player title, but I would care when the game has got some multiplayer action. Even if it is only a highscore table.
Other people are always frustrated, when someone wins because of cheating (for example: position changes, more specific: position change and direct flag capping). To prevent players from doing so is your main task here.
Keep in mind, that the cheater can always decompile, change the code, recompile and play with this client, so add checks on server side. Generally, the "Security" provided is only another, not 100%-safe option to make life for cheaters harder.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.