I would like to use pickle() to save the stats, progress, and location of a player in my text adventure. I know that pickle() write an object to a text file, and that file can be later recalled to load the information.
My curiosity is, would I be able to save the stats, inventory and last location of the player by pickling into one file? If so, how would I do this? I am not quite sure how to use pickle(), so if anyone has any spare source codes where they used pickle() which I could learn from it would be greatly appreciated. Also, would I have to create one object containing all of this information in order to pickle what I need?
And for refreshment, what is an object? I am going to go back through my tutorials to brush up on key terms and concepts, in the meantime. Thanks,
karim
mruane 0 Junior Poster in Training
Recommended Answers
Jump to PostThis might be of help
Pickle
Jump to PostHere is a typical example:
# use module pickle to save/dump and load a dictionary object # or just about any other intact object import pickle # create the test dictionary before_d = {} before_d[1]="Name 1" before_d[2]="Name 2" before_d[3]="Name 3" # pickle dump the dictionary fout = …
All 5 Replies
Agni 370 Practically a Master Poster Featured Poster
lllllIllIlllI 178 Veteran Poster
mruane 0 Junior Poster in Training
Ene Uran 638 Posting Virtuoso
mruane 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.