SaveLoader - Store complete Scenes with everything - update to 1.1

Attention: Newer Version in thread SaveLoader 2.0!

Okay not everything but the most important thinks.


Here is the SaveLoader version 1.1.
Update:

  • added saveToFile

  • saves to any filename (in property saveToFile.filename or saveLoad.filename)

  • saves as textfile with additional CRs to make it more readable and editable!

  • saves as string represenation of a dictionary

  • added loadFromFile

  • loads from any filename (in property loadFromFile.filename or saveLoad.filename)

  • replaces the scene dictionaries

  • can clear the globalDict before loading (when loadFromFile.clear or saveLoad.clear is present [I haven’t tested that yet)

  • added workaround for the stop rotation bug (setAngularVelocity([0,0,0]) see http://blenderartists.org/forum/showthread.php?t=171727

  • If an dynamic object that is not rotating is stored the angularVelocity is [0.0,0.0,0.0].

  • The problem is if you restore the object but the object is now rotating the stored angularVelocity is ignored by the physics engine.

  • The workaround is to set the smallest angularVelocity that the physics engine accepts. It is 0.00000012

I think it is in a stage where it can be used. You will find the SaveLoader Module in the SaveLoader.blend. The functions have to be called as python module (not python script).

What does it do?
It stores the elements of the objects from a scene in globalDict. Multiple scenes can be stored and restored as they have the scene name as key.

The Game actuator in Save/Load GameLogic.globalDict mode can be used to store/load the stored scenes to/from file.

What can be stored?

  • all properties

  • the position

  • the orientation

  • the scale

  • the state

  • the visibility

  • the timeOffset (of slow parent)

  • the mesh (only display mesh)

  • the actuators settings of
    [LIST]

  • ipo actuator (but it is not possible to continue the animation where it was stored outside the property mode)

  • action actuator (but it is not possible to continue the animation where it was stored outside the property mode)

  • the parent/child relationship (except vertex parent and parent to bone)
    [/LIST]
    The blend contains some interactive Demo scenes where you can have fun with the SaveLoader.

Demo Scenes:DynamicsDemo:[INDENT]Demonstrates the store and restore of pyhsics.[INDENT]T - save stored scene To file “Testfile.txt” (please store before save)
F - load scene From file “Testfile.txt” (please restore after load)
S - store the scene
R - restore scene
[/INDENT]AddObjectsDemo:Demonstrate the store and restore of added objects.[INDENT]T - save stored scene To file “Testfile.txt” (please store before save)
F - load scene From file “Testfile.txt” (please Arrow keys - move the cursor
Space - add a new object
S - store the scene
R - restore scene
[/INDENT]PosRotReplaceDemo:Demonstrate the store of position, rotation and mesh replacement.[INDENT]T - save stored scene To file “Testfile.txt” (please store before save)
F - load scene From file “Testfile.txt” (please restore after load)
1 - set cylinder mesh
2 - set cone mesh
S - store the scene
R - restore scene
[/INDENT]TransferDemo.one/two:Demonstrate how to jump to another scene from any point of the scene just by pressing a key.[INDENT]Arrow keys - move the cursor
J - jump to the other scene
[/INDENT]PortalDemo.one/two:Demonstrate a portal system. By flying to a portal you can jump to another scene. The entry point will match the exitpoint of the previous scene.[INDENT]T - save stored scene (“hyperspace”) To file “Testfile.txt” (please store before save)
F - load scene (“hyperspace”) From file “Testfile.txt” (please Arrow keys - move the porter
Fly into the portal spheres to jump to the other scene.
One portal has a portal at the same place on the other scene.
[/INDENT][/INDENT]Here is the blend it is version 1.1. Please check the AAREADME:
SaveLoader.blend (762 KB)

So now have fun

and by the way

I hope it helps
Monster

Impressive! Excellent work! I could use it if the saving was written to a file, so I can load later on! you know?

This is great. Thanks for this.

Yes, very impressive!

You can use the Game actuator for saving the globalDict to file.
I planned to add a save to file function later. That way it would be possible to edit saved files with a text editor.

If someone is interested, just now there is a function printStored() that prints the globalDict to the file “SaveLoad.txt” in the blender directory. This ist there just for debugging reasons.

I hope it helps

Very cool. Saved as a reference, Im sure I will need something like this soon.

Thanks Monster!

You can use the Game actuator for saving the globalDict to file.
I planned to add a save to file function later. That way it would be possible to edit saved files with a text editor.

If someone is interested, just now there is a function printStored() that prints the globalDict to the file “SaveLoad.txt” in the blender directory. This ist there just for debugging reasons.

That’s what I’m talking about! Now if only I was a programmer…
Thanks a lot Mr. Monster, I’ll need that very soon!

thanks monster! ive saved the file and subscripted to the thread, this will become v. useful when i start playing about with the game engine XD

Hello,
I updated the first post. You can find version 1.1 with the new functions saveToFile and loadFromFile.
The missing font texture is in the file now. So you can read the instructions :).

I will add some better tests for saveToFile and loadFromFile later. I will alo prepare a tutorial how to use the scripts. I think it is a little bit complicated to be inserted into custom blends by now. But I need some time for that.

Anyway

Happy blending

Fantastic I’ll try it in my wip!
Thank a lot! I’m very happy! I’ll wait for the tuts for more info :slight_smile:

Now, I can comment!
Your previous work was very nice, but, well, almost useless for the majority of us, here in the forum, Python illiterates.
This new version its just a wonder!!
Easy to use and seems to work perfectly!
Thank you for your effort and sharing!
Bye

Hey Monster! Great work! Would you mind if I tried to add this to APPLE? It is a module that is full of python functions. I am updating it on my own, so I am calling it BANANA.

how can I download it please