home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1998 November / maximum-cd-1998-11.iso / Truespace 4 / Data / PROGRAM / Scripts / autosave.py next >
Encoding:
Text File  |  1998-08-31  |  1.5 KB  |  50 lines

  1. # autosave script
  2. # (c) 1998 Simon Windmill, simon@wfmm.com
  3. # windmill fraser multimedia, inc.  http://www.wfmm.com/
  4. #
  5. # This is a scene script, load it and press play.  Now your scene will be
  6. # saved automatically to a backup!
  7. # You must set your tick interval to 1000
  8.  
  9. import time
  10.  
  11. # Time, in minutes, between saves 
  12. # (it is a 'constant', so we can leave it like that)
  13. TimeDelay = 1
  14.  
  15. # The base scene filename including path
  16. # Note that you must use double characters for backslashes
  17. BaseSceneName = 'c:\\temp\\leetscenebackup'
  18.  
  19. def ontimestarted():
  20.   # We need to reset some variables here
  21.  
  22.   # The number of times the scene is saved
  23.   global SceneNumber; SceneNumber = 0
  24.   global LastSavedTime; LastSavedTime = round(time.time())
  25.  
  26. def ontimechanged():
  27.   global SceneNumber, LastSavedTime
  28.  
  29.   # Check to see if it's time to save a backup
  30.   # sometimes an ontimechange() routine call is not called at the
  31.   # propper time (equal to X * TimeDelay * 60), so
  32.   # if round(time.time()) % (TimeDelay * 60) == 0:
  33.   # doesn't work
  34.   if round(time.time()) - LastSavedTime > TimeDelay * 60:
  35.  
  36.     # update last saved time var
  37.     LastSavedTime = round(time.time())
  38.  
  39.     # increment the save count..
  40.     SceneNumber = SceneNumber + 1
  41.  
  42.     # ..and save the scene
  43.     trueSpace.SaveScene(BaseSceneName + str(SceneNumber) + '.scn')
  44.     
  45.     # ..aaand also write a little message about it
  46.     print BaseSceneName + str(SceneNumber) + '.scn saved at ' + time.asctime(time.localtime(time.time()))
  47.     # this is the newline character
  48.     print '\n'
  49.  
  50.