game progress save and load help

I am making a shooter game and I was wondering if there was a way to save your in-game progress such as what level you are on and then load it later. Is this what the save and load Global.dict do?

did you check this?

http://www.blendenzo.com/tutSaveLoad.html

Yes, you can use the GameLogic.globalDict to save and load files, or you can use the older method on my website. Both of them should work fine. I haven’t had time to use the new globalDict method, but Clark has some info about it in the Python API Reference on his website. You can check it out here:

http://www.tutorialsforblender3d.com/GameModule/GameLogicModule.html
(Scroll down to the “globalDict” section to see some sample code)

Hi Jesus Freak><>,

It has been suggestedthat a save/load button be added to each Property (maybe next to the debug button) so that the Property selected would automatically be saved when the globalDict is saved and automatically loaded when the globalDict is loaded.

Moguri responded with:

That sounds awesome :slight_smile: . I’ll see what I can do
Hopefully, it will be added. It would make saving and loading games a lot easier.

Clark

how can I check is there the save file?
I use GameLogic.globalDict functions to save/load my settings but at the first start I need to check the file

You can also have a look at the SaveLoader.

In my Air Hockey game, I allow you to save the current game, then recover it later. Here’s the code I use for saving and loading variables:

To load a variable and set the object’s proper location, I just add a boolean property called “save” onto the object set as true, and an always sensor connected to this script:


GL = GameLogic
obj = GL.getCurrentController().owner

GL.objloc = obj.worldPosition

#GL.globalDIct.get("saved") is whether you clicked on the open saved game button in the menu
if (GL.globalDict.get("saved") == True) and (obj["save"] == True):
    obj.worldPosition = GL.globalDict.get("ailoc")
    obj["save"] = False

To save it, it’s pretty simple. I have this script set up to an always sensor and a save globalDict actuator.


GL = GameLogic
cont = GL.getCurrentController

GL.globalDict["ailoc"] = GL.objloc

cont.activate(cont.actuators["savedict"])

Don’t forget to load the globalDict. I have an always sensor on my camera that loads the globalDict.

I use this same concept for several variables in my game: the score, speed of the puck, the AI’s mallet location (as shown in this script), and for settings that you can set in a different scene. Always remember though, don’t forget the load globalDict and save globalDict actuator.(it’s located under the game actuator)

The advantage of using the globalDict over a text file, is somebody can’t go in and change values and cheat in the game.

I’m clueless with code but would like a save and load option, Monsters is a bit more than what I need so, how do you load the globalDict, or if I were to use blendenzo’s script, how would I modify the code to save Cube and Cube.001?