I’m using the Pickle module to save game data (dictionaries) to save files for a game I’m working on. These dictionaries contain KX_GameObjects which can’t be saved by Pickle, so I have to sort through the dictionaries and replace these objects with None values.
This is the code I’m using:
# g.blocks is the original dictionary of blocks
saveblocks = {}
for i in g.blocks:
data = g.blocks<i>
saveblocks[i] = data
for i in saveblocks:
saveblocks[i][3] = None
However, [I]any changes to the saveblocks dictionary also affects g.blocks as well, meaning that the code I used didn’t duplicate the dictionary data as I thought it would. This basically breaks the game after using the save function.
I tried using deepcopy, but it can’t process the KX_GameObject class either.
Does anyone have an idea of another way to duplicate dictionary data (not using dict.copy), preferably without having to pack additional external python modules along with the .blend?