[Newbies] Stop a script for a second

Ned Konz ned at bike-nomad.com
Tue Dec 5 16:30:13 UTC 2006


I suppose I should add to my prior state machine email that:

* You can move the delayForTicks: lines down to the bottom of the 
turnRed and turnGreen scripts; they will make more sense here (as they 
really affect the delay after the script runs).

* The stateTest object has the following variables:
- delay, a Number
- currentState, a ScriptName

* the stateMachine script is set to fire once per tick, and you can 
change the tick rate to whatever you want. If you change the tick rate 
to something other than 1 second, you might want to add a scaling factor 
to the delayForTicks: script, and rename it as delayForSeconds: or 
delayForMilliseconds: instead.

For instance, if you change the stateMachine script to tick at 10/second 
(I think the default is 8/second) you might do this for delayForSeconds:

delayForSeconds: {Number}
stateTest's delay <- Number * 10

So now you can say

stateTest delayForSeconds: 0.3

and have it work as expected.

BTW: to change the tick rate, you hold your mouse down for at least a 
second on the little clock face on the script editor. You don't want to 
change the "fires per tick"!.


-- 
Ned Konz
ned at bike-nomad.com
http://bike-nomad.com


More information about the Beginners mailing list