This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-01-26 06:02:04

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

2 more functions in Timer needed

I would like to have 2 more functions in <timer>[/blocks].

Now I can only reset a <timer>[/blocks] and cannot pause or resume it.

Do you think it's reasonable to provide these 2 functions in future release?

Offline

 

#2 2009-01-26 12:41:30

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: 2 more functions in Timer needed

easily done though...
pause:
var timer = timer()
reset timer()

play again:
timer() = var timer

("timer()" = the timer sencor, and "var timer" = a variable)

Offline

 

#3 2009-01-26 20:02:55

boinoinoi
Scratcher
Registered: 2007-06-05
Posts: 500+

Re: 2 more functions in Timer needed

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)


http://i30.tinypic.com/335fpxx.jpg
"Boinoinoi is the only person on the forums that I expect to be wearing a monocle all the time behind that screen, so I'm sure being as classy as he is, he knows what he's doing"        http://myfastcounter.com/count.php?c_style=88&amp;id=1284259111http://myfastcounter.com/count.php?c_style=88&amp;id=1286068127

Offline

 

#4 2009-01-27 00:43:52

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

Re: 2 more functions in Timer needed

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

 

#5 2009-01-27 01:39:16

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: 2 more functions in Timer needed

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.

Offline

 

#6 2009-01-27 06:59:06

bosox397
Scratcher
Registered: 2008-02-17
Posts: 1000+

Re: 2 more functions in Timer needed

yeah when they add new blocks usually u can already do the function of the block  its just the new block is a shortcut.


Dear Scratch Users,
I'm done with scratch, or at least making projects. I have made one last big game, thats both fun and teaches a lesson about water. It'd mean a lot if you gave me feedback.                              http://scratch.mit.edu/projects/bosox397/569201

Offline

 

#7 2009-01-27 17:54:26

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

Re: 2 more functions in Timer needed

I want to show the timer (with pause & resume) on screen.

Please can you give me the lines of code?

Offline

 

#8 2009-01-27 19:55:27

boinoinoi
Scratcher
Registered: 2007-06-05
Posts: 500+

Re: 2 more functions in Timer needed

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.


http://i30.tinypic.com/335fpxx.jpg
"Boinoinoi is the only person on the forums that I expect to be wearing a monocle all the time behind that screen, so I'm sure being as classy as he is, he knows what he's doing"        http://myfastcounter.com/count.php?c_style=88&amp;id=1284259111http://myfastcounter.com/count.php?c_style=88&amp;id=1286068127

Offline

 

#9 2009-01-27 22:16:24

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

Re: 2 more functions in Timer needed

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

 

#10 2009-01-28 10:21:56

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: 2 more functions in Timer needed

i guess. Either that, or simply a set timer to function and my origanl script will work

Offline

 

#11 2009-01-28 19:45:48

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

Re: 2 more functions in Timer needed

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

 

#12 2009-02-02 18:24:04

mchao
Scratcher
Registered: 2008-07-12
Posts: 7

Re: 2 more functions in Timer needed

Does anybody have an idea of a solution without performance issue?

Offline

 

Board footer