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

Great Work agoose77!!!
Thank you very much! this is really awesome and very easy to use!! :slight_smile:

Thanks a lot!

Hi, when i change between scenes script stops working. Any ideas how to fix that?

Let me look into it :slight_smile:

[](/u/agoose77
[/B)

Hello :slight_smile: This is an awesome script! But i have a problem with my game I’m making, i only use the part of the script to copy properties. But when i restart the game using the restart scene actuator, the script stops working. So when i die in my game the score doesn’t work :S
I have not learned python, I can only “understand” how it works, I can’t make my own scripts.
I would be pleased if you could tell me if this can be fixed somehow. :slight_smile:

Thanks :slight_smile:

does this work the same like checkpoints in games?

It could do, yes.

Is there a way to fix the restart/change scene issue? :confused:

Hi there, I tried to make a SaveLoader to my project looking at this example and I get the next console error:

“Error, bge.logic.globalDict could not be marshal’d
Warning: could not create marshal buffer”

Somebody can explain me what does mean?
It’s reported/crash in the save line

bge.logic.saveGlobalDict()

I paste the module…


def SaveParty():
    bge.logic.globalDict["position"][str(own)] = list(own.worldPosition) 
    bge.logic.globalDict["orientation"][str(own)] = list(own.worldOrientation[0]),list(own.worldOrientation[1]),list(own.worldOrientation[2])
    bge.logic.globalDict["position"][str(Camera)] = Camera.worldOrientation[2]
  
    for object in objects:
        if type(object) == bge.types.KX_GameObject: 
            propsInObj = object.getPropertyNames()
            if len(propsInObj) > 0: 
                bge.logic.globalDict["state"][str(object)] = object.state
                for property in propsInObj:
                    bge.logic.globalDict["properties"][str(object)] = {}
                    bge.logic.globalDict["properties"][str(object)][property] = object[property]
                for actuator in object.actuators:
                    if isinstance(actuator, BL_ActionActuator): 
                        bge.logic.globalDict["position"][str(object)] = list(object.worldPosition)
                        bge.logic.globalDict["orientation"][str(object)] = list(object.worldOrientation)
                        break
                        #print ("Object frame: ", object.getActionFrame)          

    bge.logic.saveGlobalDict()

I’ll take a look at it soon

Looks like failed in the actuator loop, I deactivate the entire loop and rules.

EDIT: “I change to string the worldPostion and worldOrientation” and now no stuck, maybe vectors create some kind of conflict …"

Can I use this is my game? I will give full credit. :slight_smile:

nice work! I will use this in my game based on “Doctor who”

Nice! useful!

In your script minus does not subtract from a property but plus does.Is that correct or do i have a bug.

I don’t know python that much and you would of probably figured this out by now, you would have to make a script that will get the proprieties of the new object you have added so that you can get the size, location, rotation and shape and also the script would also have to count all the objects that have been added so that when you save the game it will do a loop storing each of the object’s proprieties until it has saved all of the objects and its proprieties.

How do I do that to save the mysql database

I’ve updated the blend file in the first post for a better save system. Primarily because the example was now four years old, and awfully written.

Ideally, it would handle animation states and other features, but without storing a record of the animations that are stored on the object, this proves more difficult. This could be done partially by reading the actuators for action names, but if multiple actuators play on the same layer (likely) or the animations are run from Python, this proves futile.

save_load.blend (664 KB)

Whilst the old resource was poor in design, generally speaking you want to keep things separate and clear. I could have written the same script in under twenty lines, but then it would be poorly maintainable and difficult to read. Line count is not a good indication of code quality, especially the notion of compactness.