Saving and loading from three globalDict save slots

In Python, I can create a globalDict entry for saves like this:

import bge, bge.logic as gl

globaldict = gl.globalDict

try:
   save = globaldict["GAMEDATA"]

   slot1 = save["FILE_1"]
   slot2 = save["FILE_2"]
   slot3 = save["FILE_3"]

except KeyError:

   save = globaldict["GAMEDATA"] = {}

   slot1 = save["FILE_1"] = {}
   slot2 = save["FILE_2"] = {}
   slot3 = save["FILE_3"] = {}

Now, the objective I want is:

  1. Be able to save to a slot (I retrieve the slot from an object name)

  2. Being able to load from that selected slot, which is also retrieved from the object name.

  3. The slots are generated only on initialisation of the script. This checks to see if no saves exist, and if no save slots exist, they are recreated. If the active save slot is {}, it loads everything in the save slot.

It may be asking a lot, but i want to create a save/load system that is split into 3 slots - you save into the slot you choose, and once you reload the game, your savefile is still there instead of reverting to {}.

And this does not use text, json or any other format than globalDict.

you can save and load the globaldict to/from disc:

bge.logic.saveGlobalDict()
bge.logic.loadGlobalDict()