SaveLoad V.2 - Save and Load your Game in Blender Game Engine

Hello BlenderArtists!
I’ve updated this resource for better reliability, handling of multiple scenes and instanced objects.

Run the save and load controllers from to save/load the gameUse module mode rather than script mode (see the existing controllers on Cube)

To save/load all scenes, set a property called “all_scenes” to True.

To restrict saving to certain objects, give them a unique property, and set a string
property on the saving object (Cube) called “save_property” to the property name.

To omit objects from being saved, give them a unique property, and set a string
property on the saving object (Cube) called “ignore_property” to the property name.

Deleting this property from the Cube will restore global behaviour.
Instances will be saved and loaded by deleting any instances of the saved object base
object (from the hidden layer) and then re-spawning the instances as required
by the save file.

In this example, I don’t want to save any properties on the saving object (Cube)
in case we set save-configuration properties during the game -they’d be overwritten

The script saves the following information:

  • Transforms (position, orientation) in local space (to correctly deal with parenting).
  • Dynamics (velocity, angular velocity), again in local space.
  • Properties
  • Life
  • Logic state

It supports instances and static objects (referring to objects that originate from the main layer).
Any instances created from an instance which is saved in a save file are deleted when loading that file back, even if they are not specifically referenced in that file (due to non-unique identifiers)

File - save_load.blend (668 KB)

Bit of a python beginner here - been working with the game engine for a couple years now and finally realized that I really need to learn python scripting. Can you explain how to make it save specific properties? Simply adding a property to the orientation object doesn’t work, so what do I need to do in the Python console to make it save property numbers?

so does this save objects that are added to the scene?

Just glancing through the code…
It saves them in a dictionary, and where objects have the same names, it will overwrite

After testing, that is proven correct.
Added objects are not saved.

seems really strange that
we want a code so complicated to save 2 things

is not the best from agoose this :wink:

Great agoose! wow this is very nice, thanks a lot!!! we usually give stars only for the game development section of the forum i think that its good do rate this kind of thread because that way good things like this one would be easier to find.

…how about using a sql database? are there any modules about it? I’m working on a sql manager class, just for learning purposes.
But are there any better, faster, easier or more professional ways except sql? … wondering…

I don’t know!
I’ve used mySQL (and therefore sql) before, and i like it; it’s perfectly fine to use in theory.

Hi agoose, first off I need to tell you, I don’t know any Python. (Although I am watching your tutorials and others)

I was wondering if it is possible to just save one property from a big .blend (scoreboard).
I have recently found out how to type any user names in game, now I want to know how to save it to a scoreboard using a simple script. Goran madea tutorial but it’s way over my head. So, I have my string property with whatever the user types (their name), now, how do I save it so when they quit and re-open, it’s still there (in a separate scene)? Also if you do help me or add a sample.blend, remember to leave comments as to where to type in the property(s)/object(s). Thank you very much.

In summary: I want to know how to save user scores and names. And is this too complicated for me to understand, if you think not, please explain to me as it would be VERY handy!

Thanks and sorry for the nooby post,


If i am able to record a video, i shall!

Haha, thanks. If a video is too hard, you can just use a script and add plenty of comments! :slight_smile: Thanks agoose.

It’s uploading to my youtube

Really appreciate it, thanks!

Here you go!

Thanks so much agoose, I shall try it soon! If (and when :P) I run into problems, is it ok to ask here? :slight_smile:

Feel free.

I posted a modified version on the sticky you commented in, but it might not suit your needs. I’m sure you’re capable of modifying the template as you wish, so there isn’t much of a necessity to looks at the demo.

Hi, as expected, I’ve run into problems already! Keeping in mind I am in very early learning stages of Python! Heres my .Blend, I have left comments and questions in the script asking nooby questions, hopefully you don’t facepalm!

I tried to make the file as small as possible so I hop it doesn’t clog up memory or anything. Also I pretty much copied you script word for word so there MIGHT be a miss-print in there somewhere. :frowning: Thanks for reading.

i know this thread is kinda old but i was wondering if was anyway of modifing the script so it can save objects that are add into the game so have a cube hit space bart it adds a sphere save the game go back in to the game and the sphere is still there?

bump sorry

Oops I didn’t see your replies Ross and mrn. I’ll look tonight.