easily done though...
pause:
var timer = timer()
reset timer()
play again:
timer() = var timer
("timer()" = the timer sencor, and "var timer" = a variable)
Offline
Seeing as you can't actually set the timer to something, a more *reasonable* approach would be:
Pause
set var timer to (timer)
//use (var timer) for paused timer
Resume:
reset timer
//use ( (timer) + (var timer) ) instead of (timer)
Offline
Thank you boinoinoi. You got the point.
I think yambanshee has already requested "timer() = var timer" function from Scratch Team. :-)
Anyway, do you guys think it's reasonable for Scratch to provide pause and resume functions to timer?
Offline
yeah when they add new blocks usually u can already do the function of the block its just the new block is a shortcut.
Offline
Ooh. In that case you might want an on/off switch for the timer and such. one moment while I rewrite my code...
When Green Flag clicked
set [ old timer ] to [ 0 ]
set [ var timer ] to [ 0 ]
reset timer
forever
if < (pause) = (0) >
set [ var timer ] to ( ( timer ) + ( old timer ) )
else
set [ var timer ] to ( old timer )
end if
end forever
When I receive [ pause ]
if < ( ( round ( var timer ) ) = ( round ( timer ) ) ) >
set [ pause ] to ( 1 )
set [ old timer ] to ( timer )
else
set [ old timer ] to ( ( timer ) + ( var timer ) )
end if
When I receive [ resume ]
reset timer
set [ pause ] to ( 0 )
...I think.
Offline
Thanks boinoinoi. You always got my point.
boinoinoi wrote:
Ooh. In that case ...
It seems almost everyone ignores it when I heard "easily done", "They'd be handy" and "in only two lines".
boinoinoi wrote:
forever
if < (pause) = (0) >
set [ var timer ] to ( ( timer ) + ( old timer ) )
else
set [ var timer ] to ( old timer )
end if
end forever
Performance issue. The timer is in 1/10 second. Do you know how many loops will be executed in 0.1 second on a modern computer?
Again, do you guys think it's reasonable for Scratch to provide pause and resume functions to timer?
Offline
i guess. Either that, or simply a set timer to function and my origanl script will work
Offline
yambanshee wrote:
simply a set timer to function and my origanl script will work
mrweston wrote:
They'd be handy, sure, but since each statement can be written using existing blocks in only two lines, I'd think it wouldn't be a priority.
bosox397 wrote:
yeah when they add new blocks usually u can already do the function of the block its just the new block is a shortcut.
easily done though...
boinoinoi wrote:
When Green Flag clicked
set [ old timer ] to [ 0 ]
set [ var timer ] to [ 0 ]
reset timer
forever
if < (pause) = (0) >
set [ var timer ] to ( ( timer ) + ( old timer ) )
else
set [ var timer ] to ( old timer )
end if
end forever
When I receive [ pause ]
if < ( ( round ( var timer ) ) = ( round ( timer ) ) ) >
set [ pause ] to ( 1 )
set [ old timer ] to ( timer )
else
set [ old timer ] to ( ( timer ) + ( var timer ) )
end if
When I receive [ resume ]
reset timer
set [ pause ] to ( 0 )
Offline