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

  1.  
  2.  
  3.  
  4. InitTakeDictionary={} # Diccionario de funciones a lanzar al intentar coger determinados objetos
  5.  
  6.  
  7. # Funciones para gestionar dicho diccionario
  8.  
  9. def AddOnInitTakeEvent(objname, funct, flag=0):
  10.     InitTakeDictionary[objname]=[funct, flag]
  11.  
  12. def DelOnInitTakeEvent(objname):
  13.     if(InitTakeDictionary.has_key(objname)):
  14.         del InitTakeDictionary[objname] 
  15.  
  16.  
  17. # Funcion para lanzar funciones asociadas al intento de coger un determinado objeto
  18.  
  19. def OnInitTakeFunc(objname):
  20.     if(InitTakeDictionary.has_key(objname)):
  21.         InitTakeDictionary[objname][0]()
  22.         return InitTakeDictionary[objname][1]
  23.  
  24.  
  25.  
  26.  
  27.  
  28. def SaveData(filename):
  29.   import cPickle
  30.  
  31.   funcfile=open(filename,"wt")
  32.   p=cPickle.Pickler(funcfile)
  33.   d=(InitTakeDictionary,)
  34.   p.dump(d)
  35.   funcfile.close()
  36.  
  37.  
  38.  
  39. def LoadData(filename):
  40.   import cPickle
  41.  
  42.   funcfile=open(filename,"rt")
  43.   p=cPickle.Unpickler(funcfile)
  44.   d=p.load()
  45.   funcfile.close()
  46.   print d
  47.  
  48.   global InitTakeDictionary
  49.  
  50.  
  51.   InitTakeDictionary=d[0]
  52.  
  53.  
  54.  
  55. import GameState
  56. GameState.ModulesToBeSaved.append(__import__(__name__))
  57.