home *** CD-ROM | disk | FTP | other *** search
/ Alpha CD-ROM Bonus Pack / Alpha CD-ROM Bonus Pack.iso / life / shared.dir / 00502_NavButtonScripts.ls < prev    next >
Encoding:
Text File  |  1995-01-16  |  5.2 KB  |  207 lines

  1. on navButtonInit
  2.   global navBtnList, flashTimeList, gFlashTime, currentFlashState
  3.   setNavButtonDetect(0)
  4.   set navBtnList to [#Light: 40, #Back: 41, #MainMenu: 42, #quit: 43]
  5.   set navFlashTimeList to []
  6.   set flashTimeList to []
  7.   set currentFlashState to []
  8.   set gFlashTime to 0.5 * 60
  9.   repeat with i = 1 to count(navBtnList)
  10.     add(flashTimeList, 0)
  11.     add(currentFlashState, 0)
  12.   end repeat
  13.   setHandCursor(navBtnList)
  14. end
  15.  
  16. on navButtonClicked
  17.   global navBtnList, gCurrentTopicIndex
  18.   if not navButtonDetect() then
  19.     return 0
  20.   end if
  21.   setNavButtonDetect(0)
  22.   if buttonClicked(navBtnList, #MainMenu) then
  23.     returnToMainMenu()
  24.   else
  25.     if buttonClicked(navBtnList, #Back) then
  26.       if label(0) <> label("P_MainMenu") then
  27.         setTopic("P_MainMenu")
  28.         gotoTopic(theCurrentTopic())
  29.       end if
  30.     else
  31.       if buttonClicked(navBtnList, #quit) then
  32.         quitProgram()
  33.       else
  34.         if buttonClicked(navBtnList, #Light) then
  35.           flashHotSpots()
  36.         end if
  37.       end if
  38.     end if
  39.   end if
  40. end
  41.  
  42. on setNavBtnFlash btn1, btn2, btn3, btn4
  43.   global flashTimeList, navBtnList
  44.   repeat with i = 1 to count(navBtnList)
  45.     set theBtn to getPropAt(navBtnList, i)
  46.     setAt(flashTimeList, i, 0)
  47.     set sNum to getAt(navBtnList, i)
  48.     set theButton to getPropAt(navBtnList, i)
  49.     set newCast to string(theButton) & "_B1"
  50.     setAt(currentFlashState, i, 0)
  51.     puppetSprite(sNum, 1)
  52.     set the castNum of sprite sNum to the number of cast newCast
  53.     repeat with j = 1 to the paramCount
  54.       if theBtn = param(j) then
  55.         setAt(flashTimeList, i, 1)
  56.       end if
  57.     end repeat
  58.   end repeat
  59. end
  60.  
  61. on clearNavBtnFlash
  62.   global flashTimeList, navBtnList
  63.   repeat with i = 1 to count(navBtnList)
  64.     set sNum to getAt(navBtnList, i)
  65.     puppetSprite(sNum, 0)
  66.     setAt(flashTimeList, i, 0)
  67.   end repeat
  68. end
  69.  
  70. on navButtonFlash
  71.   global flashTimeList, currentFlashState, gFlashTime, navBtnList
  72.   set currentTime to the ticks
  73.   repeat with i = 1 to count(navBtnList)
  74.     set sNum to getAt(navBtnList, i)
  75.     set theButton to getPropAt(navBtnList, i)
  76.     if getAt(flashTimeList, i) = 0 then
  77.       puppetSprite(sNum, 0)
  78.       next repeat
  79.     end if
  80.     if (currentTime - getAt(flashTimeList, i)) > gFlashTime then
  81.       if getAt(currentFlashState, i) = 0 then
  82.         set newCast to string(theButton) & "_B3"
  83.         setAt(currentFlashState, i, 1)
  84.       else
  85.         set newCast to string(theButton) & "_B1"
  86.         setAt(currentFlashState, i, 0)
  87.       end if
  88.       setAt(flashTimeList, i, currentTime)
  89.       puppetSprite(sNum, 1)
  90.       set the castNum of sprite sNum to the number of cast newCast
  91.       updateStage()
  92.     end if
  93.   end repeat
  94. end
  95.  
  96. on navButtonFlash2 buttonSymbol
  97.   global flashTimeList, currentFlashState, gFlashTime
  98.   set spriteNum to getaProp(navBtnList, buttonSymbol)
  99.   set index to findPos(navBtnList, buttonSymbol)
  100.   if spriteNum <= 0 then
  101.     debug("Error inside navButtonFlash. Invalid sprite channel.")
  102.   else
  103.     if index <= 0 then
  104.       debug("Error inside navButtonFlash. Invalid index.")
  105.     else
  106.       set currentTime to the ticks
  107.       if (currentTime - getAt(flashTimeList, index)) > gFlashTime then
  108.         if getAt(currentFlashState, index) = 0 then
  109.           set newCast to string(buttonSymbol) & "_B3"
  110.           setAt(currentFlashState, index, 1)
  111.         else
  112.           set newCast to string(buttonSymbol) & "_B1"
  113.           setAt(currentFlashState, index, 0)
  114.         end if
  115.         setAt(flashTimeList, index, currentTime)
  116.         puppetSprite(spriteNum, 1)
  117.         set the castNum of sprite spriteNum to the number of cast newCast
  118.         updateStage()
  119.       end if
  120.     end if
  121.   end if
  122. end
  123.  
  124. on setNavButtonDetect theState
  125.   global gNavButtonDetect
  126.   set gNavButtonDetect to theState
  127. end
  128.  
  129. on navButtonDetect
  130.   global gNavButtonDetect
  131.   return gNavButtonDetect
  132. end
  133.  
  134. on nextTopic
  135.   global topicList, gCurrentTopicIndex
  136.   set gCurrentTopicIndex to gCurrentTopicIndex + 1
  137.   if gCurrentTopicIndex > count(topicList) then
  138.     set gCurrentTopicIndex to gCurrentTopicIndex - 1
  139.     beep()
  140.     return 0
  141.   else
  142.     gotoTopic(gCurrentTopicIndex)
  143.     return 1
  144.   end if
  145. end
  146.  
  147. on priorTopic
  148.   global topicList, gCurrentTopicIndex
  149.   set gCurrentTopicIndex to gCurrentTopicIndex - 1
  150.   if gCurrentTopicIndex < 1 then
  151.     set gCurrentTopicIndex to 1
  152.     beep()
  153.     return 0
  154.   end if
  155.   gotoTopic(gCurrentTopicIndex)
  156.   return 1
  157. end
  158.  
  159. on gotoTopic theIndex
  160.   global topicList
  161.   if (theIndex > count(topicList)) or (theIndex < 1) then
  162.     alert("Invalid list index inside 'gotoTopic' ")
  163.   else
  164.     go(label(getAt(topicList, theIndex)))
  165.   end if
  166. end
  167.  
  168. on setTopic topicName
  169.   global gCurrentTopicIndex, topicList
  170.   set topicIndex to getPos(topicList, topicName)
  171.   if topicIndex > 0 then
  172.     set gCurrentTopicIndex to topicIndex
  173.     return 1
  174.   else
  175.     return 0
  176.   end if
  177. end
  178.  
  179. on theCurrentTopic
  180.   global gCurrentTopicIndex
  181.   return gCurrentTopicIndex
  182. end
  183.  
  184. on returnToMainMenu
  185.   global gMoviePlaying
  186.   if gMoviePlaying then
  187.     if label("MainMenuReturn") > 0 then
  188.       unPuppetSprites(40, 43)
  189.       go("MainMenuReturn")
  190.     else
  191.       play done
  192.     end if
  193.   else
  194.     nothing()
  195.   end if
  196. end
  197.  
  198. on theCurrentTopicName
  199.   global topicList, gCurrentTopicIndex
  200.   return getAt(topicList, gCurrentTopicIndex)
  201. end
  202.  
  203. on quitProgram
  204.   playThesound("DEM32.AIF")
  205.   openDialog("quitDialog")
  206. end
  207.