home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1998 December / WPCDEC98.ISO / dxrs / files / startUp.dxr / 00004_soundScript.ls < prev    next >
Encoding:
Text File  |  1998-09-24  |  1.9 KB  |  78 lines

  1. property myCurrentTrack, trackPlaying, timerStart, myDelay, myMaxSound, checkFlag
  2. global gMasterObj
  3.  
  4. on new me
  5.   set trackPlaying to 0
  6.   set myCurrentTrack to 0
  7.   set checkFlag to 0
  8.   append(the actorList, me)
  9.   return me
  10. end
  11.  
  12. on stepFrame me
  13.   if trackPlaying and not soundBusy(1) and not checkFlag then
  14.     set checkFlag to 1
  15.     puppetSound(myCurrentTrack)
  16.   else
  17.     if trackPlaying and not soundBusy(1) then
  18.       set checkFlag to 0
  19.     else
  20.       if soundBusy(1) then
  21.         set checkFlag to 0
  22.       end if
  23.     end if
  24.   end if
  25. end
  26.  
  27. on playSoundTrack me, whichTrack, whatDelay, maxSound
  28.   if whichTrack <> myCurrentTrack then
  29.     set myMaxSound to maxSound
  30.     set the volume of sound 1 to myMaxSound
  31.     set myDelay to whatDelay * 60
  32.     if trackHasFadedOut(me) then
  33.       set myCurrentTrack to whichTrack
  34.       if myCurrentTrack <> 0 then
  35.         set trackPlaying to 1
  36.       else
  37.         set trackPlaying to 0
  38.       end if
  39.     end if
  40.   end if
  41. end
  42.  
  43. on trackHasFadedOut me
  44.   if soundBusy(1) then
  45.     set startSoundVolume to the volume of sound 1
  46.     set timerStart to the timer
  47.     repeat while 1
  48.       cursor(4)
  49.       if the timer > (timerStart + (myDelay / 10.0)) then
  50.         set timerStart to the timer
  51.         set the volume of sound 1 to the volume of sound 1 - (startSoundVolume / 10.0)
  52.         updateStage()
  53.         if the volume of sound 1 <= 0 then
  54.           puppetSound(1, 0)
  55.           set the volume of sound 1 to myMaxSound
  56.           cursor(-1)
  57.           exit repeat
  58.         end if
  59.       end if
  60.     end repeat
  61.   end if
  62.   return 1
  63. end
  64.  
  65. on alterVolume me, myIncrement
  66.   if (myIncrement = 1) and (myMaxSound < 255) then
  67.     set myMaxSound to myMaxSound + (255 / 10.0)
  68.     set the volume of sound 1 to myMaxSound
  69.   else
  70.     if (myIncrement = -1) and (myMaxSound > 0) then
  71.       set myMaxSound to myMaxSound - (255 / 10.0)
  72.       set the volume of sound 1 to myMaxSound
  73.     else
  74.       beep()
  75.     end if
  76.   end if
  77. end
  78.