Simple (yet bulky) save system?

Hello everyone. I’ve been using Python for a number of years now, but only recently got into Blender. Now I’m having all the fun of trying to figure out how exactly to use the Blender (and all the other) modules in Python scripts for the game engine. That aside, I was just thinking about how I would implement a save system for my game, and how I would decide what things to save, how I should store them properly, and mostly, how I could apply them back.

Then I had an idea which I haven’t tested yet, but I’m thinking may be a very, very simple solution: using the cPickle python module, I could save the instance of the scene to a file. For anyone not familiar with the pickle/cPickle modules, they serialize a data instance and convert it to a string, therefore allowing one to save an entire instance to a file, or send it through a socket, etc.

So my thoughts were, why not pickle the entire game scene instance to cram into a save game file, and then when I load it, unpickle the scene instance and set it as the current scene in Blender. I’m just not familiar yet with how the Blender module allows the loading of scene instances. So for anyone who has had much more experience with the game engine than me, does this sound perfectly viable? I’ve used the pickle module tons of times in the past for other projects, but as long as one can make a scene instance within Python, and then assign it to be the current scene, then this idea should work fine. The one drawback may be size of the serialized object file, as a scene must have a lot of properties and such.

Here’s the Python docs on the pickle module. I’d suggest using cPickle over the pickle module as it’s faster (written in C instead), but just doesn’t allow for subclassing the Pickler and Unpickler classes, but that’s not needed in this case anyways.
http://docs.python.org/library/pickle.html

Thoughts? :slight_smile: