home *** CD-ROM | disk | FTP | other *** search
/ Club KidSoft Volume 3 #3 / CKSPCV33.BIN / movies / catalog.dir / 00005_Script_5 < prev    next >
Text File  |  1995-07-19  |  5KB  |  190 lines

  1. --More movie scripts
  2. on consonantDown
  3.   global gAnswerString, gInputString, gPosition,¼
  4.        gCurrentAnswer, gCurrentInput, gInputIndex, gMIAWOpen, SUnlockCode
  5.   
  6.   if gMIAWOpen = TRUE or the visible of sprite SUnlockCode = FALSE then exit
  7.   
  8.   if the selStart = length(gAnswerString) then
  9.     set endFlag to TRUE
  10.   else
  11.     set endFlag to FALSE
  12.   end if
  13.   
  14.   
  15.   if the commandDown = TRUE then -- Let command keys through
  16.     
  17.     set wantsToQuit = FALSE
  18.     if the key = "q" then
  19.       set wantsToQuit = TRUE
  20.     else
  21.       if the machineType = 256 then -- also check for escape on the PC
  22.         if charToNum(the key) = 27 then
  23.           set wantsToQuit = TRUE
  24.         end if
  25.       end if
  26.     end if
  27.     
  28.     if wantsToQuit = TRUE then
  29.       answer "Really quit Club KidSoft?", "", "No", "Quit", 175, "QuitKidSoftDialogClose"
  30.     else
  31.       pass
  32.     end if
  33.     
  34.     pass
  35.     
  36.   else
  37.     
  38.     if the keyCode = 123 then
  39.       set endFlag to FALSE
  40.       exit
  41.     else if the keyCode = 124 then
  42.       
  43.       exit
  44.     else if the keyCode = 125 or the keyCode = 126 then
  45.       dontPassEvent
  46.       exit
  47.     end if
  48.     
  49.     set curKey = charToNum(the key)
  50.     
  51.     if the key = BACKSPACE then 
  52.       deleteHandler
  53.     else if the key = RETURN and the number of chars in field "Unlock Code" < 17 then
  54.       dontPassEvent
  55.     else if IsOKCancelKey(the key) = "OK" then
  56.       dontPassEvent
  57.       TryUnlock(script "Unlock Now")
  58.     else if not alphaTest(the key) then
  59.       dontPassEvent
  60.       -- Ignore the key if RETURN, or not a letter (upper or lower)
  61.       
  62.     else -- must be a letter key
  63.       dontPassEvent
  64.       if the number of chars of field "Unlock Code" > 16 then 
  65.         exit
  66.       end if
  67.       
  68.       set gAnswerString to the text of field "Unlock Code"
  69.       --      set gPosition to the selStart
  70.       
  71.       if curKey >= 97 then
  72.         set curKey = curKey - 32
  73.       end if
  74.       
  75.       if char 1 of gAnswerString = " " then
  76.         put numToChar(curKey) into char 1 of gAnswerString
  77.       else if the selStart <> 0 then
  78.         put numToChar(curKey) after char the selStart of gAnswerString
  79.       else
  80.         put numToChar(curKey) before char 1 of gAnswerString  
  81.       end if
  82.       
  83.       set numChars = the number of chars of gAnswerString
  84.       set gAnswerString to formatAnswer()
  85.       
  86.       
  87.       
  88.       set the text of field "Unlock Code" to gAnswerString
  89.       set daLength to length(gAnswerString)
  90.       
  91.       if daLength = 5 or daLength = 9 or daLength = 14 then
  92.         set the selEnd to the selEnd + 2
  93.         set the selStart to the selEnd
  94.       else  
  95.         set the selEnd to the selEnd + 1
  96.         set the selStart to the selEnd
  97.       end if
  98.       
  99.       
  100.       --      set the selEnd to length(gAnswerString)
  101.       --      set the selStart to length(gAnswerString)
  102.       
  103.       if numChars = 17 then 
  104.         global SUnlockNow
  105.         set the visible of sprite SUnlockNow = TRUE
  106.         updateStage
  107.         exit
  108.       else
  109.         global SUnlockNow
  110.         set the visible of sprite SUnlockNow = FALSE
  111.         updateStage
  112.         exit
  113.       end if
  114.     end if
  115.   end if
  116. end consonantDown
  117.  
  118. on formatAnswer
  119.   global gAnswerString
  120.   
  121.   set daLength to length(gAnswerString)
  122.   
  123.   if daLength < 3 then
  124.     return gAnswerString
  125.   else
  126.     repeat with i = 1 to daLength
  127.       set howFar to offset("-", gAnswerString)
  128.       if howFar then
  129.         delete char howFar of gAnswerString
  130.       end if
  131.     end repeat
  132.   end if
  133.   
  134.   put "-" after char 3 of gAnswerString
  135.   
  136.   if daLength < 7 then
  137.     --    return gAnswerString
  138.   else if daLength < 12 then
  139.     put "-" after char 7 of gAnswerString
  140.     --    return gAnswerString
  141.   else
  142.     put "-" after char 7 of gAnswerString
  143.     put "-" after char 12 of gAnswerString
  144.     --    return gAnswerString
  145.   end if
  146.   
  147.   if the last char of gAnswerString = "-" then
  148.     set i = the length of gAnswerString
  149.     delete char i of gAnswerString
  150.   end if
  151.   return gAnswerString
  152. end
  153.  
  154. on alphaTest letter
  155.   set asKey to charToNum(letter)
  156.   if (asKey < 65) or (asKey > 90 and asKey < 97) or (asKey > 122) then
  157.     return 0
  158.   else
  159.     return 1
  160.   end if
  161. end alphaTest
  162.  
  163. on deleteHandler
  164.   global gAnswerString
  165.   dontPassEvent
  166.   if the selStart = 4 or the selStart = 8 or the selStart = 13 then
  167.     delete char (the selStart - 1) of gAnswerString
  168.   else
  169.     delete char the selStart of gAnswerString
  170.   end if
  171.   set gAnswerString to formatAnswer()
  172.   set the selStart to the selStart - 1
  173.   set the selEnd to the selStart
  174.   set the text of field "Unlock Code" to gAnswerString
  175.   
  176.   if char (the selStart) of gAnswerString = "-" then
  177.     set the selStart to the selStart - 1
  178.     set the selEnd to the selStart
  179.   end if
  180.   
  181.   set numChars to the number of chars of field "Unlock Code"
  182.   if numChars < 17 then 
  183.     global SUnlockNow
  184.     set the visible of sprite SUnlockNow = FALSE
  185.     updateStage
  186.     
  187.   end if
  188.   
  189. end
  190.