Re: Writing game-state data...

Discussion in 'Python' started by Ian Kelly, Nov 9, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Fri, Nov 9, 2012 at 12:20 AM, Graham Fielding <> wrote:

    > file_object = open('savegame.sav', 'wb')


    Here you open a file and assign it to "file_object".

    > file['map'] = map


    Here you attempt to write to "file" instead of "file_object". "file"
    is the name of a built-in type, hence your error message.

    Since you seem to be trying to use shelve, you should also probably be
    calling shelve.open to open the file, not just open.

    > file['objects'] = objects
    > file['player_index'] = objects.index(player) #index of player in
    > objects list
    > file['inventory'] = inventory
    > file['game_msgs'] = game_msgs
    > file['game_state'] = game_state
    > file['stairs_index'] = objects.index(stairs)
    > file['dungeon_level'] = dungeon_level
    > file.close()


    Same issue for all these other statements.
     
    Ian Kelly, Nov 9, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BlackHawke
    Replies:
    12
    Views:
    1,599
    Andrew Thompson
    Jan 26, 2004
  2. judith
    Replies:
    0
    Views:
    1,700
    judith
    Nov 1, 2006
  3. Max Kubierschky
    Replies:
    10
    Views:
    1,877
    pabloreda
    Mar 31, 2007
  4. Mark Lawrence

    Re: Writing game-state data...

    Mark Lawrence, Nov 9, 2012, in forum: Python
    Replies:
    0
    Views:
    254
    Mark Lawrence
    Nov 9, 2012
  5. Prasad, Ramit

    RE: Writing game-state data...

    Prasad, Ramit, Nov 9, 2012, in forum: Python
    Replies:
    0
    Views:
    249
    Prasad, Ramit
    Nov 9, 2012
Loading...

Share This Page