Mechanics I'd like to implement, but don't know how to go about it...

So in my game, I wish to have a few large mechanics that I haven’t had any luck on trying to make happen.

  1. Save function: Like having an option for the player to save the game and any and all changes to the scene would be recorded.

  2. Options menu: Have a simple in-game menu, or even an external launcher for the player to change the resolution of the game or disable shadows and change volume.

  3. Score, recorded data: Kinda like saving, but a variable that goes from save to save… Like a score counter, or a counter for how many secrets you find…

  4. Installer: This doesn’t have much to do with blender, but I still cannot find any good any to make an easy installer program… Would it be best to use python and write my own?

Save = write list of all objects positions and properties and save externally

load = use list to place objects

2 - overlay edits properties of “menu” item, menu applies changes if properties are changed (you won’t be able to change resolution in game I think but I have never tried)

3- just a property of a object called scoreboard, modified in game.

4- ??? blenderplayer needs no installation.

I knew that was how #1 worked, I just didn’t know how to implement it… Same thing for number 2 really, I’ve gotten to UI part down flat, but using animations and actions for the graphical settings isn’t working properly… For number four, I was talking about when someone downloads my compiled version of the game, and say I wanted to make it easier for them and make a simple installer to move the files to a specific folder and place shortcuts, ect…

The game engine has a globaldict, I think it is bge.logic (using python). Learn about dictionaries in python, along with pickling.

For two and three, you have to save data in a place from where it can be accessed easily, there 3 options:
bge.logic.globalDict = A dictionary on where you can store whatever you want, and also you can store data on the modules bge, and bge.logic. Now you need to find a way to store that data in the pc, you can use a text file, and the configparser module.

From python api:
bge.logic.loadGlobalDict()
Loads bge.logic.globalDict from a file.
bge.logic.saveGlobalDict()
Saves bge.logic.globalDict to a file.

I made an example to show how to use the globalDict and configparser for menu options:
to save data.zip (170 KB)
Click the up and down arrows to increase and decrease the value, and click the save button to save the value in a cfg file, it will be loaded every time you open the game.

You can save values that will be used on things like volume, resolution, lenguaje, etc.

Sorry my small confusion between “in” and on" in the comments…

How can I use the data that is saved to change graphical settings or volume?

Do I just run these scripts respectively when I want to save/load?

I wouldn’t worry too much about an installer. If you go with a straight zip-file, users will generally be able to work with that fine. If you distribute on a marketplace with a client like Desura or Steam, you’ll have a “built-in” installation and uninstallation process, so no problems there either.

Okay, thank you.

Note that while I don’t know this first-hand, Steam’s installation and uninstallation (game data deletion) process all happens from within Steam, so I’m pretty sure it’s handled for you automatically.

Do you know anything about 1-3?

I use a save/load script in almost every game I make. So that when the player quits the game, then starts it at a later date, all the scores, ammo, grenades, pickups, health etc. are there. I use PhilB’s wonderful save/load script for years. (Thank you PhilB) BUT . . . it won’t work in 2.7* because it is for 2.49. Maybe someone can rewrite it for 2.7*
My games are usually very simple. There are several ways I implement the save/load. I don’t know anything about your game, so I’m not sure I can help.

So you’ll need to write a save/load script, or have someone write it for you, or find a script that will work for your game. Once you do that, maybe I and others can help you implement it.

Raco posted two GlobalDict scripts a while ago, that worked well in 2.66 when I tested them.

Monster has a save/load script also.

I use properties “Text” to store the data. I usually use property changed, to activate the save script. (So the player don’t lose anything if he dies) and a delay to load.

You can PM me if you have questions and don’t wish to reveal your blend or stuff.

Okay thanks!

No idea what 1-3 is.

My questions, 1-3… lol

Well, I specifically chose to answer question 4 because other people covered the other questions pretty well.

  1. Use a script to open a file and save your variables out, and another to open that file and load those variables in. Monster has a resources for this, like was mentioned.

  2. Use Python to make a GUI and tie it to variables - volume, resolution, whatever. Making an external launcher would just be slightly more work to do the same thing (and probably not recommended for volume or other things that you have to be in-game to hear or experience).

  3. Use the globalDict, or store variables in Python modules (either your own, or in the BGE’s modules, like bge.logic). I would recommend storing variables in your own Python modules so that it’s easy for multiple areas to have access to them and to have code completion in external editors (like PyCharm).