Use: Python controller (name does not matter) that use module
‘SaveLoad.save’ to save your scene
‘SaveLoad.load’ to load your scene
Features:
Save/Load instanced objects
Save/Load not instanced objects
Save/Load object Position
Save/Load object Orientation
Save/Load object Properties
You can choose were you want to create a save.
A blacklist (Objects in this list wont be saved)
Settings menu (in the script)
Settings can be set with object properties
Save encryption (None,Base64,Base32,Binhex)
Checksum (you can choose if you want to use it or not)
Whitelist (only objects listed in it will be saved, must be activated via settings)
Save globalDict. (If you want to save the globaldict inside the save file)
Object needed:
An empty named ‘Spawner’ somewhere in the active layer.
Example:
Arrow keys to move the cursor
WASD to rotate the cursor
1 to Save
2 to Load
ok so i cant get it to work what i have is on the main cube when i hit 1 it has the save module and when i hit 2 i has the load module but nothing happens.
Added a blacklist (Line 11 in the script).
Listed object wont be saved.
Monster
Be careful when adding parents. They add their children too. That can result in two objects (the first added via the parent, the second added via the object itself).
New features:
Settings menu (in the script)
Settings can be set with object properties
Save encryption (None,Base64,Base32,Binhex)
Checksum (you can choose if you want it or not)
Whitelist (only objects listed in it will be saved, must be activated via settings)
Save globalDict. (If you want to save the global dict inside the save)
Hi. Your work interrest me. Actually, I create a video game and I work on the savegame system. I’d like understand some thinks : in your dictionnary, you have saved the world position with string. I don’t understand why you haven’t done the same thing for the orientation.
Second question :
# save
dict = {'save_pos' : str(gl.player.worldPosition),
'save_rot' = list(gl.player.worldOrientation)
}
save.dump(dict)
print('save ok')
data.close()
#load
with open('Savegame.dat', 'rb') as data :
loading = pickle.Unpickler(data)
coord = loading.load()
pos = coord
pos = pos.strip('<>Vector() ')
pos = pos.split(',')
x = float(pos[0])
y = float(pos[1])
z = float(pos[2])
gl.player.worldPosition = mathutils.Vector((x, y, z))
You can see I succeed to load position but how can I do for two things if I must use list for record the orientation ?
1: First, the orientation was saved as a string but it was very buggy during the load so I changed it into 3 lists.The position is still saved as a string because it work perfectly and when I convert the worldposition in a list, it create huge floats (ex: 1.1 would become 1.18364825893652958926e -20).
2: When you load data from your file, it is supposed to return the dictionary you saved .
So ‘coord[‘save_pos’]’ would be the position and ‘coord[‘save_rot’]’ would be the orientation.
Then you could handle different type of data.
Furthermore I see that you converted the whole worldOrientation as a list. This return a list of 3 vector and, if I recall correctly, you can’t save vector with pickle (that’s why I converted the worldposition as a string).
This is great, thank you!
Is it possible to customize the keys somehow or to assign a sensor to a specific task
(for example “if property xy=TRUE then save”) ?
You could add an ‘‘if’’ loop in the script
OR (if you are not familiar with python)
you could use a ‘‘and’’ controller connected to a ‘‘signal’’ actuator. A ‘‘signal’’ sensor receive the signal and execute the save script .