home *** CD-ROM | disk | FTP | other *** search
/ Inventor Labs: Technology / INVENTORLABS_TECHNOLOGY.BIN / pc / files / invest.dir / 00695_Script_HeatAndTemperature < prev    next >
Text File  |  1997-05-26  |  34KB  |  1,037 lines

  1. -- Heat and Temperature Object Parent Script (oHeatTemp)
  2.  
  3.  
  4. property pHeatCapacityList
  5. property pBoilingPointList
  6. property pVapoReactionList
  7. property pTemp1
  8. property pTemp2
  9. property pFuel
  10. property pInitialPositionX
  11. property pInitialPositionY
  12. property pLiquidStart
  13. property pVessel1H
  14. property pVessel1V
  15. property pVessel2H
  16. property pVessel2V
  17. property pPad
  18. property pVessel1
  19. property pVessel2 
  20. property pMP3
  21. property pVesselStart
  22. property pBoilMovieStart
  23. property pMixMovieStart
  24.  
  25. --mCalcMix
  26. property pTestTemp1
  27. property pTestTemp2
  28. property pValue1
  29. property pValue2
  30. property pLiquid1
  31.  
  32. --mChangeTemp1
  33. property pBoilingFlag1
  34. property pNewTemp1
  35.  
  36. --mChangeTemp2
  37. property pBoilingFlag2
  38. property pNewTemp2
  39.  
  40. --mSetLiquid
  41. property pNowMe
  42. property pPosition
  43.  
  44. property pMixLiquidsButton
  45. property pAlcoholContainer
  46. property pWaterContainer
  47. property pWaxContainer
  48.  
  49. property pBeaker1
  50. property pBeaker2
  51.  
  52. property pStand1QT
  53. property pStand2QT
  54.  
  55. property pStand1QTLoop
  56. property pStand2QTLoop
  57.  
  58. property pStand1QTTarget
  59. property pStand2QTTarget
  60.  
  61. property pStand1QTFlag
  62. property pStand2QTFlag
  63.  
  64. property pStand1QTH
  65. property pStand1QTV
  66. property pStand2QTH
  67. property pStand2QTV
  68.  
  69. property pMeltWaxFlag
  70. property pFirstBoilFlag1
  71. property pFirstBoilFlag2
  72.  
  73. property pFirstFlame
  74. property pDraggableSprite -- the sprite that gets dragged when user selects a liquid
  75.  
  76. property pFlame1
  77. property pFlame2
  78. property pFlameCount
  79. property pFlame1State -- #FIRE or #OUT
  80. property pFlame2State -- #FIRE or #OUT
  81. property pFlameMod
  82. property pFlameDuration
  83.  
  84. property pMixCastList
  85. property pFirstDigit
  86. property pDigitSprite
  87. property pDigitWidth
  88. property pMixTemp
  89. property pLogs1Dig
  90. property pLogs2Dig
  91. property pTemp1H
  92. property pTemp1V
  93. property pTemp2H
  94. property pTemp2V
  95. property pMixH
  96. property pMixV
  97. property pLog1H
  98. property pLog1V
  99. property pLog2H
  100. property pLog2V
  101.  
  102. property pOldMiniBurner1
  103. property pOldMiniBurner2
  104. property pMixButtonSprite
  105. property pMixButtonCast
  106. -----------------------------
  107. on mInit me
  108.   
  109.   cursor 4
  110.   
  111.   set pFirstFlame = the number of cast "IHTFIR1.PIC"
  112.   set pFirstDigit = the number of cast "IHTNUM0.PIC"
  113.   set pDigitSprite = 4 -- sprite channel
  114.   set pDigitWidth = 8 -- pixels
  115.   
  116.   set pMixCastList = [#IHTALWT1: the number of cast "IHTALWT1.MOV", #IHTALWT2: the number of cast "IHTALWT2.MOV", #IHTALWT3: the number of cast "IHTALWT3.MOV", #IHTALWT4: the number of cast "IHTALWT4.MOV", #IHTALWX1: the number of cast "IHTALWX1.MOV", #IHTALWX2: the number of cast "IHTALWX2.MOV", #IHTALWX3: the number of cast "IHTALWX3.MOV", #IHTALWX4: the number of cast "IHTALWX4.MOV", #IHTWXWT1: the number of cast "IHTWXWT1.MOV", #IHTWXWT2: the number of cast "IHTWXWT2.MOV", #IHTWXWT3: the number of cast "IHTWXWT3.MOV", #IHTWXWT4: the number of cast "IHTWXWT4.MOV", #IHTMEAL1: the number of cast "IHTMEAL1.MOV", #IHTMEAL2: the number of cast "IHTMEAL2.MOV", #IHTMEAL3: the number of cast "IHTMEAL3.MOV", #IHTMEAL4: the number of cast "IHTMEAL4.MOV", #IHTMEWT1: the number of cast "IHTMEWT1.MOV", #IHTMEWT2: the number of cast "IHTMEWT2.MOV", #IHTMEWT3: the number of cast "IHTMEWT3.MOV", #IHTMEWT4: the number of cast "IHTMEWT4.MOV", #IHTMEWX1: the number of cast "IHTMEWX1.MOV", #IHTMEWX2: the number of cast "IHTMEWX2.MOV", #IHTMEWX3: the number of cast "IHTMEWX3.MOV", #IHTMEWX4: the number of cast "IHTMEWX4.MOV"]
  117.   
  118.   set pMixButtonSprite = 8
  119.   set pMixButtonCast = the number of cast "MixButton.Op state"
  120.   set pBeaker1 = 13
  121.   set pBeaker2 = 14
  122.   set pStand1QT = 5
  123.   set pStand2QT = 6
  124.   set pFlame1 = 23
  125.   set pFlame2 = 24
  126.   
  127.   -- establish lists init
  128.   set pHeatCapacityList = [.95,1.,.8,.445]
  129.   set pBoilingPointList = [78.,100.,324.,1000.]
  130.   set pVapoReactionList = [153.,414.,40.,1000.] 
  131.   
  132.   -- set melting point (for wax only) init
  133.   set pMP3 = 56
  134.   
  135.   -- set initial values for vessels (value indicates which liquid it contains)
  136.   set pVessel1 = 0
  137.   set pVessel2 = 0
  138.   
  139.   -- set the amount of pFuel added per click 
  140.   set pFuel = 10
  141.   
  142.   -- set the sprite location of the top liquid container
  143.   set pLiquidStart = 17
  144.   
  145.   -- set castnum of first vessel pict
  146.   set pVesselStart = the number of cast "alcohol.pict"
  147.   
  148.   -- set number of first boiling movie
  149.   set pBoilMovieStart = the number of cast "IHTALBL.MOV"
  150.   
  151.   -- set number of first mix movie
  152.   set pMixMovieStart = the number of cast "IHTALWT1.MOV"
  153.   
  154.   -- set up lists for initial positions of liquid containers
  155.   set pInitialPositionX = [4]
  156.   set pInitialPositionY = [4]
  157.   
  158.   -- set positions of vessels
  159.   set pVessel1H = 255
  160.   set pVessel1V = 224
  161.   set pVessel2H = 558
  162.   set pVessel2V = 224
  163.   
  164.   -- set the tolerance for locating a container on the burner
  165.   set pPad = 40
  166.   
  167.   -- set fire parameters
  168.   set pFlameMod = 1
  169.   set pFlame1State = #OUT
  170.   set pFlame2State = #OUT
  171.   set pFlameDuration = 15 -- @15fps = 1 second
  172.   
  173.   set pDraggableSprite = 21
  174.   set pMixTemp = 0
  175.   set pLogs1Dig = 0
  176.   set pLogs2Dig = 0
  177.   
  178.   return me
  179.   
  180. end mInit
  181. -----------------------------
  182. on mActivate me
  183.   
  184.   -- set puppetSprites 
  185.   puppetSprite pMixLiquidsButton,true
  186.   puppetSprite pAlcoholContainer,true
  187.   puppetSprite pWaterContainer,true
  188.   puppetSprite pMercuryContainer,true
  189.   puppetSprite pWaxContainer,true
  190.   puppetSprite pFlame1,true
  191.   puppetSprite pFlame2,true
  192.   
  193.   set pMeltWaxFlag = #NOMELT
  194.   set pFirstBoilFlag1 = #DONTBOIL
  195.   set pFirstBoilFlag2 = #DONTBOIL
  196.   
  197.   -- get QT locations for burner stands
  198.   set pStand1QTH = the locH of sprite 5 -- pStand1QT
  199.   set pStand1QTV = the locV of sprite 5 -- pStand1QT
  200.   set pStand2QTH = the locH of sprite 6 -- pStand2QT
  201.   set pStand2QTV = the locV of sprite 6 -- pStand2QT
  202.   
  203.   set pStand1QTFlag = #OFF
  204.   set pStand2QTFlag = #OFF
  205.   
  206.   set the puppet of sprite pStand1QT = 1
  207.   set the puppet of sprite pStand2QT = 1
  208.   
  209.   -- now move the QTs out of the way
  210.   set the loc of sprite pStand1QT = point(-100, -100)
  211.   set the loc of sprite pStand2QT = point(-100, -100)
  212.   
  213.   -- turn off flames 
  214.   set the visible of sprite pFlame1 to false
  215.   set the visible of sprite pFlame2 to false
  216.   
  217.   -- set initial temps of vessels 
  218.   set pTemp1 = 35
  219.   set pTemp2 = 35
  220.   
  221.   -- constrain draggable sprite
  222.   set the constraint of sprite pDraggableSprite = 3
  223.   
  224.   -- set initial positions of liquid containers 
  225.   repeat with x = pLiquidStart to pLiquidStart+3
  226.     setAt(pInitialPositionX,x-16,the loch of sprite x)
  227.     setAt(pInitialPositionY,x-16,the locv of sprite x)
  228.   end repeat
  229.   
  230.   set pTemp1H = the locH of sprite 7
  231.   set pTemp1V = the locV of sprite 7
  232.   
  233.   set pTemp2H = the locH of sprite 8
  234.   set pTemp2V = the locV of sprite 8
  235.   
  236.   set pMixH = the locH of sprite 9
  237.   set pMixV = the locV of sprite 9
  238.   
  239.   set pLog1H = the locH of sprite 10
  240.   set pLog1V = the locV of sprite 10
  241.   
  242.   set pLog2H = the locH of sprite 11
  243.   set pLog2V = the locV of sprite 11
  244.   
  245.   cursor -1
  246.   
  247. end mActivate
  248. -----------------------------
  249. on mClose me
  250.   puppetSprite pMixLiquidsButton,false
  251.   puppetSprite pAlcoholContainer,false
  252.   puppetSprite pWaterContainer,false
  253.   puppetSprite pMercuryContainer,false
  254.   puppetSprite pWaxContainer,false
  255.   puppetSprite pFlame1,false
  256.   puppetSprite pFlame2,false
  257.   set the visible of sprite pMixLiquidsButton to true
  258.   set the visible of sprite pFlame1 to true
  259.   set the visible of sprite pFlame2 to true
  260.   
  261.   --tj&dl
  262.   repeat with n = 2 to 20
  263.     set the puppet of sprite n = 0
  264.     set the visible of sprite n = 1
  265.   end repeat
  266.   
  267.   set the constraint of sprite pDraggableSprite = 0
  268.   puppetsprite 33,  false
  269. end mClose
  270. -----------------------------
  271. on mDisplayDigits me
  272.   -- pTemp1Dig, pTemp2Dig, pMixTempDig, pLogs1Dig, pLogs2Dig
  273.   set pTemp1Dig = integer(pTemp1)
  274.   set pTemp2Dig = integer(pTemp2)
  275.   set pMixTempDig = integer(pMixTemp)
  276.   
  277.   set the trails of sprite pDigitSprite = 1
  278.   
  279.   if not(sprite pDraggableSprite intersects 7) then
  280.     -- display pTemp1Dig
  281.     set TheNumber = pTemp1Dig
  282.     if TheNumber > 999 then set TheNumber = 999
  283.     set Hundreds = TheNumber/100
  284.     set TheNumber = TheNumber mod 100
  285.     set Tens = TheNumber/10
  286.     set TheNumber = TheNumber mod 10
  287.     set Ones = TheNumber
  288.     
  289.     repeat while TRUE
  290.       set the castNum of sprite pDigitSprite = pFirstDigit + Hundreds
  291.       set the locH of sprite pDigitSprite = pTemp1H
  292.       set the locV of sprite pDigitSprite = pTemp1V
  293.       updateStage
  294.       set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  295.       set the locH of sprite pDigitSprite = pTemp1H + pDigitWidth
  296.       set the locV of sprite pDigitSprite = pTemp1V
  297.       updateStage
  298.       set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  299.       set the locH of sprite pDigitSprite = pTemp1H + (pDigitWidth * 2)
  300.       set the locV of sprite pDigitSprite = pTemp1V
  301.       updateStage
  302.       exit repeat
  303.     end repeat
  304.   end if
  305.   
  306.   -- display pTemp2Dig
  307.   if not(sprite pDraggableSprite intersects 9) then
  308.     set TheNumber = pTemp2Dig
  309.     if TheNumber > 999 then set TheNumber = 999
  310.     set Hundreds = TheNumber/100
  311.     set TheNumber = TheNumber mod 100
  312.     set Tens = TheNumber/10
  313.     set TheNumber = TheNumber mod 10
  314.     set Ones = TheNumber
  315.     
  316.     repeat while TRUE
  317.       set the castNum of sprite pDigitSprite = pFirstDigit + Hundreds
  318.       set the locH of sprite pDigitSprite = pTemp2H
  319.       set the locV of sprite pDigitSprite = pTemp2V
  320.       updateStage
  321.       set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  322.       set the locH of sprite pDigitSprite = pTemp2H + pDigitWidth
  323.       set the locV of sprite pDigitSprite = pTemp2V
  324.       updateStage
  325.       set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  326.       set the locH of sprite pDigitSprite = pTemp2H + (pDigitWidth * 2)
  327.       set the locV of sprite pDigitSprite = pTemp2V
  328.       updateStage
  329.       exit repeat
  330.     end repeat
  331.   end if
  332.   
  333.   -- display pMixTempDig
  334.   if not(sprite pDraggableSprite intersects 12) then
  335.     set TheNumber = pMixTempDig
  336.     if TheNumber > 999 then set TheNumber = 999
  337.     set Hundreds = TheNumber/100
  338.     set TheNumber = TheNumber mod 100
  339.     set Tens = TheNumber/10
  340.     set TheNumber = TheNumber mod 10
  341.     set Ones = TheNumber
  342.     
  343.     repeat while TRUE
  344.       set the castNum of sprite pDigitSprite = pFirstDigit + Hundreds
  345.       set the locH of sprite pDigitSprite = pMixH
  346.       set the locV of sprite pDigitSprite = pMixV
  347.       updateStage
  348.       set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  349.       set the locH of sprite pDigitSprite = pMixH + pDigitWidth
  350.       set the locV of sprite pDigitSprite = pMixV
  351.       updateStage
  352.       set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  353.       set the locH of sprite pDigitSprite = pMixH + (pDigitWidth * 2)
  354.       set the locV of sprite pDigitSprite = pMixV
  355.       updateStage
  356.       exit repeat
  357.     end repeat
  358.   end if
  359.   
  360.   -- display pLogs1Dig
  361.   if not(sprite pDraggableSprite intersects 16) then
  362.     set TheNumber = pLogs1Dig
  363.     if TheNumber > 99 then set TheNumber = 99
  364.     set Tens = TheNumber/10
  365.     set TheNumber = TheNumber mod 10
  366.     set Ones = TheNumber
  367.     
  368.     repeat while TRUE
  369.       set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  370.       set the locH of sprite pDigitSprite = pLog1H
  371.       set the locV of sprite pDigitSprite = pLog1V
  372.       updateStage
  373.       set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  374.       set the locH of sprite pDigitSprite = pLog1H + pDigitWidth
  375.       set the locV of sprite pDigitSprite = pLog1V
  376.       updateStage
  377.       exit repeat
  378.     end repeat
  379.   end if
  380.   
  381.   -- display pLogs2Dig
  382.   if not(sprite pDraggableSprite intersects 22) then
  383.     set TheNumber = pLogs2Dig
  384.     if TheNumber > 99 then set TheNumber = 99
  385.     set Tens = TheNumber/10
  386.     set TheNumber = TheNumber mod 10
  387.     set Ones = TheNumber
  388.     
  389.     repeat while TRUE
  390.       set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  391.       set the locH of sprite pDigitSprite = pLog2H
  392.       set the locV of sprite pDigitSprite = pLog2V
  393.       updateStage
  394.       set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  395.       set the locH of sprite pDigitSprite = pLog2H + pDigitWidth
  396.       set the locV of sprite pDigitSprite = pLog2V
  397.       updateStage
  398.       exit repeat
  399.     end repeat
  400.   end if
  401. end mDisplayDigits
  402. -----------------------------
  403. on mGenericDisplay me, TheNumber, H, V
  404.   set the trails of sprite pDigitSprite = 1
  405.   if TheNumber > 999 then set TheNumber = 999
  406.   set Hundreds = TheNumber/100
  407.   set TheNumber = TheNumber mod 100
  408.   set Tens = TheNumber/10
  409.   set TheNumber = TheNumber mod 10
  410.   set Ones = TheNumber
  411.   repeat while TRUE
  412.     set the castNum of sprite pDigitSprite = pFirstDigit + Hundreds
  413.     set the locH of sprite pDigitSprite = H
  414.     set the locV of sprite pDigitSprite = V
  415.     updateStage
  416.     set the castNum of sprite pDigitSprite = pFirstDigit + Tens
  417.     set the locH of sprite pDigitSprite = H + pDigitWidth
  418.     set the locV of sprite pDigitSprite = V
  419.     updateStage
  420.     set the castNum of sprite pDigitSprite = pFirstDigit + Ones
  421.     set the locH of sprite pDigitSprite = H + (pDigitWidth * 2)
  422.     set the locV of sprite pDigitSprite = V
  423.     updateStage
  424.     exit repeat
  425.   end repeat
  426. end mGenericDisplay
  427. -----------------------------
  428. on mMixButtonClicked me
  429.   if pVessel1 <> 0 and pVessel2 <> 0 then
  430.     if pVessel1 = 3 then
  431.       if pFirstBoilFlag1 = #GARBAGE or pFirstBoilFlag1 = #ALREADYBOILING then
  432.         set the puppet of sprite pMixButtonSprite = 1
  433.         set the castNum of sprite pMixButtonSprite = (pMixButtonCast + 1)
  434.         mCalcMix me
  435.       end if
  436.     else if pVessel2 = 3 then
  437.       if pFirstBoilFlag2 = #GARBAGE or pFirstBoilFlag2 = #ALREADYBOILING then
  438.         set the puppet of sprite pMixButtonSprite = 1
  439.         set the castNum of sprite pMixButtonSprite = (pMixButtonCast + 1)
  440.         mCalcMix me
  441.       end if
  442.     else
  443.       set the puppet of sprite pMixButtonSprite = 1
  444.       set the castNum of sprite pMixButtonSprite = (pMixButtonCast + 1)
  445.       mCalcMix me
  446.     end if
  447.   end if
  448. end mMixButtonClicked
  449. -----------------------------
  450. on mPassClickOn me, ClickedItem
  451.   set pNowMe = ClickedItem
  452. end
  453. -----------------------------
  454. on mCheckForQTDone me
  455.   if pStand1QTFlag = #ON then
  456.     if the movieTime of sprite pStand1QT >= pStand1QTTarget then
  457.       set pStand1QTFlag = #OFF
  458.       set the movieRate of sprite pStand1QT = 0
  459.       set the movieTime of sprite pStand1QT = pStand1QTTarget -- pStand1QTLoop
  460.     end if
  461.   end if
  462.   if pStand2QTFlag = #ON then
  463.     if the movieTime of sprite pStand2QT >= pStand2QTTarget then
  464.       set pStand2QTFlag = #OFF
  465.       set the movieRate of sprite pStand2QT = 0
  466.       set the movieTime of sprite pStand2QT = pStand2QTTarget -- pStand2QTLoop
  467.     end if
  468.   end if
  469. end
  470. -----------------------------
  471. on mTurnOffQTStand me
  472.   if pStand1QTFlag = #ON then
  473.     set the movieRate of sprite pStand1QT = 0
  474.     set pStand1QTFlag = #OFF
  475.   end if
  476.   if pStand2QTFlag = #ON then
  477.     set the movieRate of sprite pStand2QT = 0
  478.     set pStand2QTFlag = #OFF
  479.   end if
  480. end
  481. -----------------------------
  482. on mCalcMix me
  483.   -- determine values for model based on which liquid is in which vessel
  484.   mDetermineValues me
  485.   
  486.   set BP1 = getAt(pBoilingPointList,pValue1)
  487.   set BP2 = getAt(pBoilingPointList,pValue2)
  488.   set HCP1 = getAt(pHeatCapacityList,pValue1)
  489.   set HCP2 = getAt(pHeatCapacityList,pValue2)
  490.   set VAP1 = getAt(pVapoReactionList,pValue1)
  491.   
  492.   -- determine the delta energy change for each vessel from current state to boiling point of
  493.   -- liquid in vessel 1. If there is more heat in vessel 2, then liquid in vessel 1 will boil
  494.   -- when mixed
  495.   
  496.   set deltaH1 = (BP1-pTestTemp1)*HCP1
  497.   set deltaH2 = (pTestTemp2-BP1)*HCP2
  498.   
  499.   -- if there is not enough energy in vessel 2 to make the liquid in vessel 1 boil, then 
  500.   -- calculate the mix temp from the vessel temperatures
  501.   
  502.   if deltaH2 < deltaH1 then
  503.     set tempMix = (pTestTemp2*HCP2+pTestTemp1*HCP1)/(HCP1+HCP2)
  504.     set pLiquid1 = 1
  505.     set vapor1 = 0
  506.   else
  507.     
  508.     -- if there is excess heat in liquid 2, then determine the amount of boiling
  509.     
  510.     if deltaH2 < VAP1+deltaH1 then
  511.       
  512.       -- if there is not enough excess heat in liquid 2 to boil off all of liquid 1, 
  513.       -- then calculate the fraction of liquid 1 left
  514.       
  515.       set tempMix = BP1
  516.       set Vapor1 = ((pTestTemp1-tempMix)*HCP1+(pTestTemp2-tempMix)*HCP2)/VAP1
  517.       set pLiquid1 = 1-Vapor1
  518.     else
  519.       
  520.       -- if there is enough excess heat in liquid 2 to boil off liquid 1, then
  521.       -- calculate temperature of liquid 2 that remains
  522.       
  523.       set Vapor1 = 1
  524.       set pLiquid1 = 0
  525.       set tempMix = (HCP2*pTestTemp2+HCP1*pTestTemp1-VAP1)/(HCP1+HCP2)
  526.     end if
  527.   end if
  528.   
  529.   set pMixTemp = integer(tempMix)
  530.   
  531.   mDisplayDigits me
  532.   
  533.   set the puppet of sprite pStand1QT to 0
  534.   set the puppet of sprite pStand2QT to 0
  535.   set the puppet of sprite pBeaker1 to 0
  536.   set the puppet of sprite pBeaker2 to 0
  537.   set the puppet of sprite pFlame1 to 0
  538.   set the puppet of sprite pFlame2 to 0
  539.   set the visible of sprite pFlame1 to 0
  540.   set the visible of sprite pFlame2 to 0
  541.   
  542.   go frame "HT_MIXLIQUIDS"
  543.   
  544. end mCalcMix
  545. -----------------------------------
  546. on mChangeTemp1 me
  547.   -- check to see if vessel 1 has liquid
  548.   if pVessel1 = 0 then
  549.   else
  550.     
  551.     -- mReset boiling flag
  552.     set pBoilingFlag1 = 0
  553.     
  554.     -- increment number of logs
  555.     set pLogs1Dig = pLogs1Dig + 1
  556.     
  557.     -- if temperature is less than boiling point, increase temperature
  558.     if pTemp1 < getAt(pBoilingPointList,pVessel1) then
  559.       set pNewTemp1 = pTemp1 + pFuel/getAt(pHeatCapacityList,pVessel1)
  560.       repeat with TheNumber = integer(pTemp1) to integer(pNewTemp1)
  561.         mGenericDisplay me, TheNumber, pTemp1H, pTemp1V
  562.       end repeat
  563.     end if
  564.     
  565.     -- if vessel 1 contains wax and temp is just below melting point
  566.     -- then don't increase temperature on this round and play melting animation
  567.     
  568.     if pVessel1 = 3 then -- wax
  569.       if pTemp1 > pMP3-pFuel and pTemp1 < pMP3 then -- wax is melting
  570.         set pNewTemp1 = pMP3
  571.         set pMeltWaxFlag = #MELTWAX -- play melting animation
  572.       end if
  573.     else -- not wax, so wax can't melt
  574.       set pMeltWaxFlag = #NOMELT
  575.     end if
  576.     
  577.     if pNewTemp1 > getAt(pBoilingPointList,pVessel1) then
  578.       set pNewTemp1 = getAt(pBoilingPointList,pVessel1)
  579.       set pBoilingFlag1 = 1
  580.     end if
  581.     
  582.     mDoLiquidAnimation1 me
  583.     
  584.     set pTemp1 = pNewTemp1
  585.     
  586.   end if
  587.   
  588. end mChangeTemp1
  589. -----------------------------------
  590. on mChangeTemp2 me
  591.   -- check to see if pVessel2 has a liquid
  592.   if pVessel2 = 0 then
  593.   else
  594.     
  595.     -- mReset boiling flag
  596.     set pBoilingFlag2 = 0
  597.     
  598.     -- increment number of logs
  599.     set pLogs2Dig = pLogs2Dig + 1
  600.     
  601.     if pTemp2 < getAt(pBoilingPointList,pVessel2) then
  602.       set pNewTemp2 = pTemp2 + pFuel/getAt(pHeatCapacityList,pVessel2)
  603.       repeat with TheNumber = integer(pTemp2) to integer(pNewTemp2)
  604.         mGenericDisplay me, TheNumber, pTemp2H, pTemp2V
  605.       end repeat
  606.     end if
  607.     
  608.     -- if vessel 2 contains wax and temp is just below melting point
  609.     -- then don't increase temperature on this round and play melting animation
  610.     
  611.     if pVessel2 = 3 then -- wax
  612.       if pTemp2 > pMP3 and pTemp2 < pMP3+pFuel/(getAt(pHeatCapacityList,pVessel2)) then
  613.         set pNewTemp2 = pMP3
  614.         set pMeltWaxFlag = #MELTWAX -- play melting animation
  615.       end if
  616.     else -- not wax, so wax can't melt
  617.       set pMeltWaxFlag = #NOMELT
  618.     end if
  619.     
  620.     if pNewTemp2 > getAt(pBoilingPointList,pVessel2) then
  621.       set pNewTemp2 = getAt(pBoilingPointList,pVessel2)
  622.       set pBoilingFlag2 = 1
  623.     end if
  624.     
  625.     mDoLiquidAnimation2 me
  626.     
  627.     set pTemp2 = pNewTemp2
  628.     
  629.   end if
  630. end mChangeTemp2
  631. -----------------------------------
  632. on mReset me
  633.   repeat with x = 2 to 24
  634.     puppetSprite x,false
  635.   end repeat
  636.   
  637.   set the visible of sprite pOldMiniBurner1 = 1
  638.   set the visible of sprite pOldMiniBurner2 = 1
  639.   set the visible of sprite pFlame1 = 0
  640.   set the visible of sprite pFlame2 = 0
  641.   
  642.   set pMeltWaxFlag = #NOMELT
  643.   set pFirstBoilFlag1 = #DONTBOIL
  644.   set pFirstBoilFlag2 = #DONTBOIL
  645.   
  646.   set pTemp1 = 35
  647.   set pTemp2 = 35
  648.   set pMixTemp = 0
  649.   set pVessel1 = 0
  650.   set pVessel2 = 0
  651.   set pLogs1Dig = 0
  652.   set pLogs2Dig = 0
  653.   
  654.   set the visible of sprite pMixLiquidsButton to true
  655.   
  656.   go to frame "HT_Main"
  657.   
  658. end mReset
  659.  
  660. -----------------------------------
  661.  
  662. on mDetermineValues me
  663.   -- this handler set the values for the mixCalc handler based on the
  664.   -- liquids in the vessels. this is necessary because the mixCalc
  665.   -- handler needs to know which liquid is in which vessel. The liquid with
  666.   -- the lower boiling point (the lowest number) is placed in pPosition 1 (pValue1)
  667.   
  668.   if pVessel1 <= pVessel2 then
  669.     set pValue1 = pVessel1
  670.     set pValue2 = pVessel2
  671.     set pTestTemp1 = pTemp1
  672.     set pTestTemp2 = pTemp2
  673.   else
  674.     set pValue1 = pVessel2
  675.     set pValue2 = pVessel1
  676.     set pTestTemp1 = pTemp2
  677.     set pTestTemp2 = pTemp1
  678.   end if
  679.   
  680. end mDetermineValues
  681.  
  682. -----------------------------
  683. --DL
  684. on mSetLiquid me
  685.   set xtemp = the mouseh
  686.   set ytemp = the mousev
  687.   
  688.   set the castnum of sprite pNowMe to 0 -- (pNowMe-pLiquidStart+pVesselStart)
  689.   set the castNum of sprite pDraggableSprite = (pNowMe-pLiquidStart+pVesselStart)
  690.   
  691.   if the castNum of sprite pBeaker1 = the castNum of sprite pDraggableSprite then
  692.     nothing
  693.   else if the castNum of sprite pBeaker2 = the castNum of sprite pDraggableSprite then
  694.     nothing
  695.   else
  696.     repeat while the mousedown
  697.       set the loch of sprite pDraggableSprite = mouseH()
  698.       set the locv of sprite pDraggableSprite = mousev()
  699.       mDisplayDigits me
  700.       updateStage
  701.     end repeat
  702.     
  703.     set liquidNum = pNowMe-pLiquidStart+1
  704.     
  705.     mCheckPosition me
  706.     
  707.     if pPosition = 1 then
  708.       set pFirstBoilFlag1 = #DONTBOIL -- make sure paramter is reset for new liquid
  709.       set pVessel1 = liquidNum
  710.       set the puppet of sprite pBeaker1 = 1
  711.       set the loch of sprite pBeaker1 to pVessel1H
  712.       set the locv of sprite pBeaker1 to pVessel1V
  713.       set the castNum of sprite pBeaker1 = the castNum of sprite pDraggableSprite
  714.       set pTemp1 = 35
  715.       
  716.       -- check to see if vessel 1 is already occupied
  717.       if pVessel1 = 0 then
  718.         nothing
  719.       else
  720.         repeat with n = pLiquidStart to (pLiquidStart + 3)
  721.           set the puppet of sprite n = 0
  722.         end repeat
  723.       end if
  724.     else if pPosition = 2 then
  725.       set pFirstBoilFlag2 = #DONTBOIL -- make sure paramter is reset for new liquid
  726.       set pVessel2 = liquidNum
  727.       set the puppet of sprite pBeaker2 = 1
  728.       set the loch of sprite pBeaker2 to pVessel2H
  729.       set the locv of sprite pBeaker2 to pVessel2V
  730.       set the castNum of sprite pBeaker2 = the castNum of sprite pDraggableSprite
  731.       set pTemp2 = 35
  732.       
  733.       -- check to see if vessel 2 is already occupied
  734.       if pVessel2 = 0 then
  735.         nothing
  736.       else
  737.         repeat with n = pLiquidStart to (pLiquidStart + 3)
  738.           set the puppet of sprite n = 0
  739.         end repeat
  740.       end if
  741.     else
  742.       set the castNum of sprite pDraggableSprite = 0
  743.       set the loch of sprite pDraggableSprite to getAt(pInitialPositionX,liquidNum)
  744.       set the locv of sprite pDraggableSprite to getAt(pInitialPositionY,liquidNum)
  745.     end if
  746.     
  747.   end if
  748.   
  749. end mSetLiquid
  750. ---------------------------------
  751. on mCheckPosition me
  752.   set pPosition = 0
  753.   
  754.   set testx = the loch of sprite pDraggableSprite
  755.   set testy = the locv of sprite pDraggableSprite
  756.   
  757.   -- check to see if mouseUp was over boiler pPad 1
  758.   if testx > pVessel1H-pPad and testx < pVessel1H+pPad then
  759.     if testy > pVessel1V-pPad and testy < pVessel1V+pPad then
  760.       set the visible of sprite pOldMiniBurner1 = 1
  761.       set pOldMiniBurner1 = pNowMe
  762.       set the visible of sprite pOldMiniBurner1 = 0
  763.       set pPosition = 1
  764.       set pLogs1Dig = 0
  765.     end if
  766.   end if
  767.   
  768.   -- check to see if mouseUp was over boiler pPad 2
  769.   if testx > pVessel2H-pPad and testx < pVessel2H+pPad then
  770.     if testy >pVessel2V-pPad and testy < pVessel2V+pPad then
  771.       set the visible of sprite pOldMiniBurner2 = 1
  772.       set pOldMiniBurner2 = pNowMe
  773.       set the visible of sprite pOldMiniBurner2 = 0
  774.       set pPosition = 2
  775.       set pLogs2Dig = 0
  776.     end if
  777.   end if
  778.   
  779. end mCheckPosition
  780. --------------------------
  781. on mDoLiquidAnimation1 me
  782.   
  783.   if pVessel1 = 1 then set WhichLiq = "Alcohol"
  784.   else if pVessel1 = 2 then set WhichLiq = "Water"
  785.   else if pVessel1 = 3 then set WhichLiq = "Wax"
  786.   else set WhichLiq = "Mercury"
  787.   
  788.   if pMeltWaxFlag = #MELTWAX then
  789.     -- Wax is melting
  790.     mSetupQT me, 1, "IHTWXBL.MOV", 0, 120
  791.     set pMeltWaxFlag = #NOMELT
  792.     set pFirstBoilFlag1 = #GARBAGE
  793.     
  794.   else if pFirstBoilFlag1 = #FIRSTBOIL then
  795.     mSetupQT me, 1, "IHTWXBL.MOV", 121, 180
  796.     set pMeltWaxFlag = #NOMELT
  797.     set pFirstBoilFlag1 = #ALREADYBOILING
  798.     
  799.   else if pBoilingFlag1 = 1 then
  800.     -- something is boiling
  801.     -- this is the first time it's boiling
  802.     if pVessel1 = 1 then
  803.       mSetupQT me, 1, "IHTALBL.MOV", 0, 60
  804.       set pMeltWaxFlag = #NOMELT
  805.       set pFirstBoilFlag1 = #ALREADYBOILING
  806.     else if pVessel1 = 2 then
  807.       mSetupQT me, 1, "IHTWTBL.MOV", 0, 60
  808.       set pMeltWaxFlag = #NOMELT
  809.       set pFirstBoilFlag1 = #ALREADYBOILING
  810.     else if pVessel1 = 3 then
  811.       mSetupQT me, 1, "IHTWXBL.MOV", 181, 300
  812.       set pMeltWaxFlag = #NOMELT
  813.       set pFirstBoilFlag1 = #ALREADYBOILING
  814.     end if
  815.     
  816.   else if pFirstBoilFlag1 = #ALREADYBOILING then
  817.     -- whatever it is, it's boiled already
  818.     if pVessel1 = 1 then
  819.       mSetupQT me, 1, "IHTALBL.MOV", 61, 240
  820.       set pMeltWaxFlag = #NOMELT
  821.     else if pVessel1 = 2 then
  822.       mSetupQT me, 1, "IHTWTBL.MOV", 61, 240
  823.       set pMeltWaxFlag = #NOMELT
  824.     else if pVessel1 = 3 then
  825.       mSetupQT me, 1, "IHTWXBL.MOV", 181, 300
  826.     end if
  827.     
  828.   else
  829.     nothing
  830.   end if
  831.   
  832.   mStartFlame me, 1
  833.   
  834.   set xtemp = pTemp1
  835.   
  836. end mDoLiquidAnimation1
  837. --------------------------
  838. on mDoLiquidAnimation2 me
  839.   
  840.   if pVessel2 = 1 then set WhichLiq = "Alcohol"
  841.   else if pVessel2 = 2 then set WhichLiq = "Water"
  842.   else if pVessel2 = 3 then set WhichLiq = "Wax"
  843.   else set WhichLiq = "Mercury"
  844.   
  845.   if pMeltWaxFlag = #MELTWAX then
  846.     -- Wax is melting
  847.     mSetupQT me, 2, "IHTWXBL.MOV", 0, 120
  848.     set pMeltWaxFlag = #NOMELT
  849.     set pFirstBoilFlag2 = #GARBAGE
  850.     
  851.   else if pFirstBoilFlag2 = #FIRSTBOIL then
  852.     mSetupQT me, 2, "IHTWXBL.MOV", 121, 180
  853.     set pMeltWaxFlag = #NOMELT
  854.     set pFirstBoilFlag2 = #ALREADYBOILING
  855.     
  856.   else if pBoilingFlag2 = 1 then
  857.     -- something is boiling
  858.     -- this is the first time it's boiling
  859.     if pVessel2 = 1 then
  860.       mSetupQT me, 2, "IHTALBL.MOV", 0, 60
  861.       set pMeltWaxFlag = #NOMELT
  862.       set pFirstBoilFlag2 = #ALREADYBOILING
  863.     else if pVessel2 = 2 then
  864.       mSetupQT me, 2, "IHTWTBL.MOV", 0, 60
  865.       set pMeltWaxFlag = #NOMELT
  866.       set pFirstBoilFlag2 = #ALREADYBOILING
  867.     else if pVessel2 = 3 then
  868.       mSetupQT me, 2, "IHTWXBL.MOV", 181, 300
  869.       set pMeltWaxFlag = #NOMELT
  870.       set pFirstBoilFlag2 = #ALREADYBOILING
  871.     end if
  872.     
  873.   else if pFirstBoilFlag2 = #ALREADYBOILING then
  874.     -- whatever it is, it's boiled already
  875.     if pVessel2 = 1 then
  876.       mSetupQT me, 2, "IHTALBL.MOV", 61, 240
  877.       set pMeltWaxFlag = #NOMELT
  878.     else if pVessel2 = 2 then
  879.       mSetupQT me, 2, "IHTWTBL.MOV", 61, 240
  880.       set pMeltWaxFlag = #NOMELT
  881.     else if pVessel2 = 3 then
  882.       mSetupQT me, 2, "IHTWXBL.MOV", 181, 300
  883.     end if
  884.     
  885.   else
  886.     nothing
  887.   end if
  888.   
  889.   mStartFlame me, 2
  890.   
  891.   set xtemp = pTemp2
  892.   
  893. end mDoLiquidAnimation2
  894. --------------------------
  895. on mStartFlame me, WhichFlame
  896.   set pFlameCount = 0
  897.   if WhichFlame = 1 then
  898.     set pFlame1State = #FIRE
  899.     set the puppet of sprite pFlame1 = TRUE
  900.     set the visible of sprite pFlame1 = TRUE
  901.   else if WhichFlame = 2 then
  902.     set pFlame2State = #FIRE
  903.     set the puppet of sprite pFlame2 = TRUE
  904.     set the visible of sprite pFlame2 = TRUE
  905.   end if
  906. end mStartFlame
  907. --------------------------
  908. on mFlameAnimation me
  909.   set pFlameCount = pFlameCount + 1
  910.   
  911.   if pFlame1State = #FIRE then
  912.     if pFlameCount mod pFlameMod = 0 then set the castNum of sprite pFlame1 = (pFirstFlame + random(2))
  913.   end if
  914.   if pFlame2State = #FIRE then
  915.     if pFlameCount mod pFlameMod = 0 then set the castNum of sprite pFlame2 = (pFirstFlame + random(2))
  916.   end if
  917.   
  918.   if pFlameCount >= pFlameDuration then
  919.     set pFlame1State = #OUT
  920.     set pFlame2State = #OUT
  921.     set the visible of sprite pFlame1 = FALSE
  922.     set the visible of sprite pFlame2 = FALSE
  923.   end if
  924. end mFlameAnimation
  925. --------------------------
  926. on mSetupQT me, WhichStand, QTName, QTStart, QTStop
  927.   if WhichStand = 1 then
  928.     set the puppet of sprite pStand1QT = 1
  929.     set QTCastNum = the number of cast QTName
  930.     set the castNum of sprite pStand1QT = QTCastNum
  931.     set pStand1Duration = the duration of cast QTName
  932.     set the locH of sprite pStand1QT = pStand1QTH
  933.     set the locV of sprite pStand1QT = pStand1QTV
  934.     updateStage
  935.     set the movieTime of sprite pStand1QT = QTStart
  936.     set the movieRate of sprite pStand1QT = 1
  937.     set pStand1QTLoop = QTStart
  938.     set pStand1QTTarget = QTStop
  939.     set pStand1QTFlag = #ON
  940.   else
  941.     set the puppet of sprite pStand2QT = 1
  942.     set QTCastNum = the number of cast QTName
  943.     set the castNum of sprite pStand2QT = QTCastNum
  944.     set pStand2Duration = the duration of cast QTName
  945.     set the locH of sprite pStand2QT = pStand2QTH
  946.     set the locV of sprite pStand2QT = pStand2QTV
  947.     updateStage
  948.     set the movieTime of sprite pStand2QT = QTStart
  949.     set the movieRate of sprite pStand2QT = 1
  950.     set pStand2QTLoop = QTStart
  951.     set pStand2QTTarget = QTStop
  952.     set pStand2QTFlag = #ON
  953.   end if
  954. end
  955. --------------------------
  956. on mDoMixAnimation me
  957.   -- this routine will play the appropriate mix animation depending on which
  958.   -- liquids are in the containers and the value of pLiquid1 (as determined in
  959.   -- the mCalcMix routine)
  960.   --
  961.   -- you might try squaring the values of vessel 1 and 2 and then 
  962.   -- adding them. This should result in a unique number that you can then use to set the castnum
  963.   -- of the movies. For example: testnum = pVessel1*pVessel1+pVessel2*pVessel2
  964.   -- possible values: 17 (alcohol & water)
  965.   --                  82 (alcohol & wax)
  966.   --                 257 (alcohol & mercury)
  967.   --                  97 (water & wax)
  968.   --                 272 (water & mercury)
  969.   --                 337 (wax & mercury)
  970.   --
  971.   -- if alcohol and water are mixed and ...
  972.   --    pLiquid1 = 1 then play movie "IHTALWT1.MOV"
  973.   --    pLiquid1 < .7 then play movie "IHTALWT2.MOV"
  974.   --    pLiquid1 < .5 then play movie "IHTALWT3.MOV"
  975.   --    pLiquid1 = 0 then play movie "IHTALWT4.MOV"
  976.   --
  977.   -- if alcohol and wax are mixed and ...
  978.   --    pLiquid1 = 1 then play movie "IHTALWX1.MOV"
  979.   --    pLiquid1 < .7 then play movie "IHTALWX2.MOV"
  980.   --    pLiquid1 < .5 then play movie "IHTALWX3.MOV"
  981.   --    pLiquid1 = 0 then play movie "IHTALWX4.MOV"
  982.   --
  983.   -- if water and wax are mixed and ...
  984.   --    pLiquid1 = 1 then play movie "IHTWXWT1.MOV"
  985.   --    pLiquid1 < .7 then play movie "IHTWXWT2.MOV"
  986.   --    pLiquid1 < .5 then play movie "IHTWXWT3.MOV"
  987.   --    pLiquid1 = 0 then play movie "IHTWXWT4.MOV"
  988.   --
  989.   -- if alcohol and mercury are mixed and ...
  990.   --    pLiquid1 = 1 then play movie "IHTMEAL1.MOV"
  991.   --    pLiquid1 < .7 then play movie "IHTMEAL2.MOV"
  992.   --    pLiquid1 < .5 then play movie "IHTMEAL3.MOV"
  993.   --    pLiquid1 = 0 then play movie "IHTMEAL4.MOV"
  994.   --
  995.   -- if water and mercury are mixed and ...
  996.   --    pLiquid1 = 1 then play movie "IHTMEWT1.MOV"
  997.   --    pLiquid1 < .7 then play movie "IHTMEWT2.MOV"
  998.   --    pLiquid1 < .5 then play movie "IHTMEWT3.MOV"
  999.   --    pLiquid1 = 0 then play movie "IHTMEWT4.MOV"
  1000.   --
  1001.   -- if waX and mercury are mixed and ...
  1002.   --    pLiquid1 = 1 then play movie "IHTMEWX1.MOV"
  1003.   --    pLiquid1 < .7 then play movie "IHTMEWX2.MOV"
  1004.   --    pLiquid1 < .5 then play movie "IHTMEWX3.MOV"
  1005.   --    pLiquid1 = 0 then play movie "IHTMEWX4.MOV"
  1006.   --
  1007.   -- please note that these movies appear in this exact order in the cast window
  1008.   
  1009.   -- figure out which mix movie to play
  1010.   set IDList = ["AL", "WT", "WX", "ME"]
  1011.   set FirstString = getAt(IDList, pVessel1)
  1012.   set SecondString = getAt(IDList, pVessel2)
  1013.   
  1014.   if pLiquid1 = 0 then set LiquidID = 4
  1015.   else if pLiquid1 < 0.5 then set LiquidID = 3
  1016.   else if pLiquid1 < 0.7 then set LiquidID = 2
  1017.   else if pLiquid1 <= 1 then set LiquidID = 1
  1018.   
  1019.   set SearchSymbol1 = value("#" & "IHT" & FirstString & SecondString & LiquidID)
  1020.   set SearchSymbol2 = value("#" & "IHT" & SecondString & FirstString & LiquidID)
  1021.   
  1022.   set CastPos = getAProp(pMixCastList, SearchSymbol1)
  1023.   if voidP(CastPos) then set CastPos = getAProp(pMixCastList, SearchSymbol2)
  1024.   
  1025.   set the puppet of sprite 9 = 1
  1026.   set the castnum of sprite 9 = CastPos
  1027.   set the movieTime of sprite 9 = 0
  1028.   set the movieRate of sprite 9 = 1
  1029.   
  1030. end mDoMixAnimation
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.