2
\$\begingroup\$

I want to create an abstraction layer between my Jython Script objects and my Game Objects. I am not making the all of the engine in Jython. Most of my game logic is in Java. I just want to expose high level functionality. I am thinking of using these classes.

Abstraction Map

  1. Jython Object is created using a Jython class and a Java interface that is coerced into java.
  2. Abstracted Object and Abstraced Map are objects with get() functions that limit the exposure of the underlying Game Map and Game Object.
  3. Game Object and Game Map are the underlying Java objects. They are wrapper classes for a component based system.
  4. Action Factory provide functionality to Jython Object. My game is a turn based tactic, so any change in the game board is done by a set of generic actions (move, damage, apply buff, etc).

This is the first time I have tried to implement a scripting system. The goal is be able to design objects and abilities in Jython. Also create a modding system. I have read several places that creating an abstraction layer is a good idea. I am just not sure how to do it.

\$\endgroup\$
0
1
\$\begingroup\$

I think you are a bit confused what an abstraction layer is.

An abstraction layer handles the communication between the game engine and the scripts. It's basically a bunch of functions which are exposed to the scripts and can be called by them and some hooks for the engine into the script engine to invoke script functions.

The abstraction layer hides the messy translation from static-typed programming language to script language and vice versa.

Jython can import and use any Java class. So you can just use any java object from Jython.

It might be worth considering what functionality should be handled by your engine and which by the scripts. Which features do you want to expose to scripting?

\$\endgroup\$
1
  • \$\begingroup\$ I want to script ability effects. Most of my objects are described by data (JSON), but complex ability effects are difficult to describe just with data. I distilled ability effects into of a collection of about 15 Actions (damage, buff, move, etc). All the script needs to access is what object is on a certain location (tile based), limited info about the object (IDs, flags, hp, team), the ability to configure and fire actions, and a few helper functions. How do I expose the functions to the script? Do I give it an object, are they static, or something else? \$\endgroup\$
    – mobo
    Jul 21 '13 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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