Game Logic: saveGlobalDict

saveGlobalDict()
  • Saves the globalDict to your computer hard drive. 
Note:
  • globalDict is saved/loaded from same directory as blend file
     
  • globalDict is saved/loaded with the blend name and an extension of .bgeconf
Example:
  • Castle.blend in C:\MyBlenderGame
  • bge.logic.saveGlobalDict() saves the globalDict in C:\MyBlenderGame as Castle.bgeconf
  • bge.logic.loadGlobalDict() loads Castle.bgeconf from C:\MyBlenderGame as the globalDict
Sample Code

################## save the Global Dictionary
  

# import bge
import bge

# if you haven't already, create a global dictionary
# create a regular dictionary for player 1 stats
player1_Stats = {  "Health" : 80,
"Armor" : 30,
"Class" : "Cleric"  }
              
# create a regular dictionary for player 2 stats
player2_Stats = {  "Health" : 60,
  "Armor" : 90,
  "Class" : "Warrior"  }
 

# save player 1 and player 2 dictionarys to the Blender globalDict
bge.logic.globalDict["player1"] = player1_Stats
bge.logic.globalDict["player2"] = player2_Stats

# save the global dictionary to the hard drive
bge.logic.saveGlobalDict()