Property Maintenance Between Game Files

I’ve been looking for a reliable method of maintaining properties between game files - something like the portal script used in YoFrankie! (which is the script I had been using originally, but it doesn’t function at all in 2.6 and I can’t find a way to make it work, despite updating the script using what I know about the changes between 2.49 and 2.5). If someone could send a link to a script or demo file that provide I would be quite thankful.

Basically, what I need is this:

  • Keep property values (i.e. health, points, etc) when switching between different game files.
  • Save/Load the player’s location - including which game file the player was located in when the game was last saved.
  • A “portal” method, so that I can simply create small empties with a portal property to determine where the player is loaded (such as those found in the YoFrankie! tutorial files from 2.4)

Thanks

use GlobalDict to save properties across .blend files

to write value to property


from bge import logic as gl
gl.globalDict["property1"]= value

value can be sting, integer, float, list etc.

to read property anywhere from the game.


from bge import logic as gl
variable=gl.globalDict["property1"]

use the bge.logic.saveGlobalDict() to save and bge.logic.loadGloablDict() to load entries in globaldict to and from save file.

Do a search on the forum, i’m sure that this has been discussed earlier.

Optionally you can use plain python for that I think, storing what you want into a file and then reading its contents when and where you want.

If You choose to store it to file Yourself I strongly recommend the json module: http://docs.python.org/py3k/library/json.html

Thanks!

I’m new to Python itself, but I’ll figure them out. Thanks again!