'From Squeak3.1alpha of 5 February 2001 [latest update: #3781] on 5 March 2001 at 9:05:26 am'! "Change Set: singleTick Date: 5 March 2001 Author: Bob Arning Scripts which have been out of the world and then return can have a huge number of ticks accumulated. A better fix would be to reset when a script leaves/enters the world. Also, if the system is falling behind, this attempt to catch up can result in falling further behind, leading to sluggish behavior and termination of ticking status. Whether the user really wants this catch up behavior needs to be determined (often she will not, I suspect) and better ways of doing it need to be found"! !ScriptInstantiation methodsFor: 'running' stamp: 'RAA 3/5/2001 09:04'! runIfTicking: nowTick | ticks rate | status == #ticking ifFalse:[^self]. rate _ self tickingRate. (lastTick == nil or:[nowTick < lastTick]) ifTrue:[lastTick _ nowTick. ticks _ 1] ifFalse:[ticks _ (nowTick - lastTick * rate / 1000) asInteger]. ticks <= 0 ifTrue:[^self]. "Scripts which have been out of the world and then return can have a huge number of ticks accumulated. A better fix would be to reset when a script leaves/enters the world. Also, if the system is falling behind, this attempt to catch up can result in falling further behind, leading to sluggish behavior and termination of ticking status. Whether the user really wants this catch up behavior needs to be determined (often she will not, I suspect) and better ways of doing it need to be found" ticks _ 1. 1 to: ticks * self frequency do:[:i | player perform: selector]. lastTick _ nowTick. ticks > 10 ifTrue:[ "check if we're lagging behind" (ticks <= (Time millisecondClockValue - lastTick * rate / 1000) asInteger) ifTrue:[ "e.g., time to run script is higher than number of ticks" self status: #paused. self updateAllStatusMorphs. ]. ].! !