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

#1 2013-04-23 12:18:31

kember
New Scratcher
Registered: 2013-04-23
Posts: 6

measuring time with a variable

Dear Scratchers!

The aim would be to measure time by using a variable. What we wanted to achieve was to get the time variable change second-by-second until the space was pressed. the whole process was going to be started by clicking on the green flag. The variable does change as we wanted it to, however, hitting the space button does not achieve anything. Any suggestions why? Thanks!

when gf clicked
repeat until <key [space] pressed?>
 wait (1) secs
 change [time] by (1)
end
stop all

Offline

 

#2 2013-04-23 12:57:17

EH7meow
Scratcher
Registered: 2013-03-23
Posts: 24

Re: measuring time with a variable

OK, I think I might have identified the problem. The "key space pressed" block that you are using only works if it is pressed down when the script gets repeated using the "repeat until" block. You can hit the space bar any time in between and it will not work.
To avoid this problem do:

when gf clicked
forever
wait (1) secs
change [time] by (1)

when [space] key pressed
stop all


Love lovehearts? Love mending lovehearts? Then you'll love Love Doctor

Offline

 

#3 2013-04-24 05:31:53

kember
New Scratcher
Registered: 2013-04-23
Posts: 6

Re: measuring time with a variable

Thank you very much! It works!  smile

Offline

 

#4 2013-04-24 15:36:58

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: measuring time with a variable

you could also use the timer in the 'sensing' drawer.

when gf clicked
reset timer
forever
   if <key [space v] pressed?>
      think (timer)
   end

Offline

 

Board footer