all.
I'm currently trying to use cPickle to create a 'save_game' function for my Roguelike.
save_game() pickles the game-state properly, but if I exit the game, the load_game() function flatly refuses to acknowledge that the pickled file exists when I try to reopen the saved game (it just tells me that there's no saved data to load).
Here's save_game():
def save_game():
#Write the game data to a cPickled file
f = open('savegame', 'wb')
cPickle.dump('map',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('objects',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('player_index',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('stairs_index', f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('inventory',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('game_msgs',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('game_state',f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump('dungeon_level',f, protocol=cPickle.HIGHEST_PROTOCOL)
f.close()
and this is load_game():
f = open('savegame', 'rb')
cPickle.load(f)
f.close()
Am I doing this properly, or is it all bass-ackwards? lol