home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Ontake.py < prev    next >
Encoding:
Text File  |  2000-10-27  |  1.2 KB  |  66 lines

  1.  
  2.  
  3.  
  4. TakeDictionary={} # dictionary of functions
  5.  
  6. #
  7. #   This function adds an event to the dictionary
  8. #############################################################
  9. def AddOnTakeEvent(objname, funct):
  10.   TakeDictionary[objname] = funct
  11.   
  12. #
  13. #   This function adds an event to the dictionary
  14. #############################################################
  15. def DelOnTakeEvent(objname):
  16.   if( TakeDictionary.has_key( objname ) ):
  17.     del  TakeDictionary[objname] 
  18.  
  19. #
  20. #   This function call an object if is added to the inventory.
  21. #  The name of the object is the only parameter
  22. #############################################################
  23. def OnTakeFunc(objname):
  24.   if( TakeDictionary.has_key( objname ) ):
  25.     TakeDictionary[ objname ]()
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. def SaveData(filename):
  36.   import cPickle
  37.  
  38.   funcfile=open(filename,"wt")
  39.   p=cPickle.Pickler(funcfile)
  40.   d=(TakeDictionary,)
  41.   p.dump(d)
  42.   funcfile.close()
  43.  
  44.  
  45.  
  46. def LoadData(filename):
  47.   import cPickle
  48.  
  49.   funcfile=open(filename,"rt")
  50.   p=cPickle.Unpickler(funcfile)
  51.   d=p.load()
  52.   funcfile.close()
  53.   print d
  54.  
  55.   global TakeDictionary
  56.  
  57.  
  58.   TakeDictionary=d[0]
  59.  
  60.  
  61. import GameState
  62. GameState.ModulesToBeSaved.append(__import__(__name__))
  63.  
  64.  
  65.  
  66.