how to save a game (realtime environment)?

(inka) #1

Is it possible to change something within the realtime environment, and keep the changes even when leaving it. I think there should be a way to save the last state. Is this possible with the Game-Engine?

Thanx, Ingo

(gorgan_almi) #2

It is possible. You would need to use a script to read the position/orientation/properties of every object and store them in a dictionary indexed against some ID that you choose for each object. Then you export that dictionary to a file, and when you want to reload, you use a script to read that dictionary from the file and work through every entry restoring the position/orientation/properties of each object.

Not the niced of tasks but thats the only way I can think of doing it. :-?

(gargola) #3

hopefuly they will add a saving and loading system for a future blender release.

(guru202) #4

I think Lagan has made a script for this. Check with him on it. I’m pretty sure he has figured this out. Also, check with blended_HKU. HKU has a
whole setup for saving and loading. Find them and get their help.

Check for HKU in the python forum. Peace

(inka) #5

Thanks. I looked for the script and found it here:

I havn’t tested yet, but maybe soon.


(gorgan_almi) #6

Yeah that script seems to work the same way I suggested. It only allows you to save 1 objects data though, not every object. You’d end up with a different save game file for every object you want to save.

(guru202) #7

BlendedHKU developed a new way to use the game engine
all that it requires is time to figure it out. I’m sure he’d help you too.
So, go to thiis link and contact him.

(gorgan_almi) #8

Hmmm… sounds pretty much like what I’ve done in my game.

I’ve got every object calling a regObj script at the beginning of the scene. this script stores/retrieves the objects data in a dictionary inside the GameLogic object. when the script is called it checks to see if that object already has its data stored in the dictionary. If it has then it restores the data to the object, and if it hasn’t then it reads all the objects relevent data and stores it in the dictionary.

This means that the objects properties are automatically restored to it at the beginning of each scene, thus eliminating the problem of transfering data between different scenes. And saving the data is simply a a case of retrieving the dictionary and storing it as text in a file.