Reputation: 15656
I currently write a small game engine for 2D games in java.
As part of the engine I want to support scripts as the main way to implement in-game events.
As I want to implement a save-game function I will have to get the current state of the scripts in a format I can store in a file and load again at a later point.
How do they deal with multithreading and calls to java code?
Are there any good resources for this problem online?
Thanks
Edit: For clarity of what I want to do
I would like to know if there are any scripting engines for java which support pausing and storing their internal state in such a way.
(Support for the official java scripting api is not required)
Upvotes: 1
Views: 432
Reputation: 18449
What you are talking about is essentially the running of coroutines, along with the ability to serialise a coroutine's state. Sadly I know little about Java or the scripting facilities available to it, but some game developers use Lua, which features coroutines, with Pluto, a serialisation library that - I'm told - allows you to save out all your individual coroutine states. Obviously this means that all the relevant state is in the coroutine and that such references that get saved out still make sense when you read them back in - this typically means access through predictable handles and ID values.
Upvotes: 1
Reputation: 609
I am not sure if this is a solution for your problem. Here are some of the scripting engine i know that work in jvm
May be this article will help
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/
Upvotes: 0