I made a save/load script that load objects with save_property in it, if there are objects added after the last save and you load the game again, it will remove those objects.
#obj is -- for obj in scene.objects #obj_name is -- obj.name.+unique number if 'save_properties' in obj: name = obj_name+'_properties' if name in bge.logic.globalDict: print("- loading", obj_name, "properties.") prop = bge.logic.globalDict[name] for prop_name, prop_value in prop.items(): obj[prop_name] = prop_value else: print('- error: ',obj_name,' not found in savefile, object removed from game') obj.endObject()
But how do i add objects that are in the save file and are killed after saving, while you load the game again.
walking around, you see 2 enemies ahead.
- you save the game
walking to the enemies, bang… bang… one died, omg you made a mistake…
- You load the game
Hey, where is that other enemy gone to…i did load the game right…wtf…?"
As you see the data is there but there is no object to put it into.
I mean, if i have loaded all objects and there are more objects in the globaldict left, then i want to spawn these objects.
Was thinking to move an empty to the location of the object, then let the empty add that object, then set the correct properties on it.
But how do i check the globaldict for the objects that have not been “loaded”?