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