title: How to change boolean from False to True using functions
body: <p>I've been coding a text based RPG, to become familiar with classes, functions, and modules, and how they interact and relate to each other.  Currently, I have a room, really a function, that works a bit like a hub-type area to interconnect 3 different rooms.  I'm going to post a bit of code here, and elaborate more on my problem after this block of code.  The code looks a little like this (simplified to show my point):</p>
  
  <pre><code>def room_hub():
      movement = raw_input("[W] for North, [D] for East, and [A] for West:").lower()
      if movement == 'd':
          if room_E_bool == False:
               print "You have moved East! "
               room_East()
  
          elif room_E_bool == True:
               print "You have already been to that room! "
               room_hub()
  
  def room_East():
      print "There's treasure here!"
      treasure = raw_input("Press [Y] to collect treasure! ").lower()
      if treasure == 'y':
           room_E_bool = True
           print "You have collected treasure!"
           print "Returning to the hub area!"
           room_hub()
      else:
          print "Not a valid command!"
          room_hub()
  </code></pre>
  
  <p>The idea is that I want a boolean value changed when the user runs through a function.  That way, when they return to the hub like area, they won't be allowed to revisit a certain room.  Of course, this may not be a very good method of doing something like this, and if that's the case, I'd like to be presented with other solutions to this issue of restricting players from certain rooms once they visited them.  </p>
  
  <p>I've tried having the boolean as a global variable, listing it at the top of the Python file, so that the hub function can reference the boolean value to determine what options are available.  However, it seems both this method of a global boolean, and a localized one inside of a function, doesn't work well in terms of declaring a new boolean value.  </p>
  
  <p>Is there a way I can use booleans to determine whether or not a player has ran through a certain function, or are there better means of doing this?</p>
  
  <p>EDIT:
  Here is the chunck of code I am referencing.  I moved the boolean to change values after the player types [D]; however, it still cycles through and allows them back into the room. </p>
  
  <pre><code>def area_1_c(self):
      global dungeon_area_1
      dungeon = dungeon_area_1()
      print "You step into a hub like area."
      print "There are three ways to go: "
      print "North, east and west. "
      print ' '
      print "You can now also view your inventory anytime by pressing [I] when prompted for a choice. "
      print ' '
      print "Press [W] for North, [D] for East, [A] for West, [I] to view inventory."
      input = raw_input("What is your next choice?: ").lower()
      while input:
          if input == 'w':
              dungeon.area_1_f()
              print " "
  
          elif input == 'd':
              bool = False
              if bool == True:
                  print "You have already explored this area. "
                  print ' '
                  input = raw_input("What is your next choice?: ").lower()
                  continue
              else:
                  bool = True
                  print "You walk towards the east. "
                  print ' '
                  dungeon.area_1_d()
  
          elif input == 'a':
              dungeon.area_1_e()
  
          elif input == 'i':
              print inventory
              print ' '
              input = raw_input("What is your choice?: ").lower()
              continue    
  
          else:
              return
  
  def area_1_d(self):
      print "You push open an iron door, behind it lies a room decorated in vines and insects."
      print "Out of the corner of your eye, you notice a chest.  You walk towards it. "
      input = raw_input("Press [Y] to open chest.: ").lower()
      if input == 'y':
          x = random.randint(1, 20)
          global dungeon_area_1
          if x &gt;= 10:
              print "You open the chest and reveal 20 gold!"
              inventory["Gold"] = (inventory["Gold"] + 20)
              print "You turn around and walk out the door, back to the hub area. "
              dungeon = dungeon_area_1()
              dungeon.area_1_c()
  
          elif x &lt; 10:
              print "You open the chest and reveal 5 gold!"
              inventory["Gold"] = (inventory["Gold"] + 5)
              print "You turn around and walk out the door, back to the hub area. "
              dungeon = dungeon_area_1()
              dungeon.area_1_c()
  </code></pre>
  
  <p>Sorry if the code is messy and what not.  It is still far, far away from being finished.</p>