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

#1 2010-07-03 07:52:00

Gveradux
Scratcher
Registered: 2010-06-18
Posts: 100+

TImer help

Hi, I need help with the timer. Every 20 seconds, I want my cat to get hungrier. You can see what i'm doing at:

http://scratch.mit.edu/projects/Gveradux/1169065


I really need that script or my game will be endless. Plz help.

Offline

 

#2 2010-07-03 07:57:35

MaxtheWeirdo
Scratcher
Registered: 2010-03-18
Posts: 500+

Re: TImer help

if timer(sensing) > 20
reset timer
[insert the cat getting hungrier]

That should do it.


My website. Hall Crawler My Awesome OS
It's just marketing, guys! Nothing sinister!

Offline

 

#3 2010-07-03 10:45:51

coka
Scratcher
Registered: 2007-11-03
Posts: 1000+

Re: TImer help

Or you could do this:
http://i49.tinypic.com/6fz955.gif
Hope this helps!  wink


http://i42.tinypic.com/2rot8c2.png

Offline

 

#4 2010-07-03 16:15:24

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: TImer help

I've tried using this:
http://i45.tinypic.com/2vx2lv6.gif
But it doesn't seem to work. Does anyone know why? (Not that it really matters; the solutions above me work fine.)

Last edited by Harakou (2010-07-03 16:29:44)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2010-07-03 16:31:03

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: TImer help

Flag
set hunger to 0
reset timer
forever if < |(timer)| > |20| >
change hunger by 1
reset timer
____________


You can now reach me on Twitter @johnnydean1_

Offline

 

#6 2010-07-03 16:55:10

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: TImer help

Harakou wrote:

I've tried using this:
http://i45.tinypic.com/2vx2lv6.gif
But it doesn't seem to work. Does anyone know why? (Not that it really matters; the solutions above me work fine.)

Hmm... I tried using that too and it didn't work. I think it might just be because the "forever" doesn't repeat fast enough to catch the 10th of a second when the timer is divisible by 20. Try making a variable named "timer" and changing it once a second, like this:

http://img821.imageshack.us/img821/6858/changehungerevery20secs.gif


http://i48.tinypic.com/2z5pqad.png

Offline

 

#7 2010-07-03 17:00:20

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: TImer help

scmb1 wrote:

Harakou wrote:

I've tried using this:
http://i45.tinypic.com/2vx2lv6.gif
But it doesn't seem to work. Does anyone know why? (Not that it really matters; the solutions above me work fine.)

Hmm... I tried using that too and it didn't work. I think it might just be because the "forever" doesn't repeat fast enough to catch the 10th of a second when the timer is divisible by 20. Try making a variable named "timer" and changing it once a second, like this:

http://img821.imageshack.us/img821/6858/changehungerevery20secs.gif

Right, I've tried that, and it works. But since the <wait [ ] seconds> block isn't very accurate, the other above solutions work better.  hmm


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#8 2010-07-03 17:06:16

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: TImer help

Harakou wrote:

scmb1 wrote:

Harakou wrote:

I've tried using this:
http://i45.tinypic.com/2vx2lv6.gif
But it doesn't seem to work. Does anyone know why? (Not that it really matters; the solutions above me work fine.)

Hmm... I tried using that too and it didn't work. I think it might just be because the "forever" doesn't repeat fast enough to catch the 10th of a second when the timer is divisible by 20. Try making a variable named "timer" and changing it once a second, like this:

http://img821.imageshack.us/img821/6858 … 20secs.gif

Right, I've tried that, and it works. But since the <wait [ ] seconds> block isn't very accurate, the other above solutions work better.  hmm

Yeah, I agree. The only situation where it would be might be better to use mine is if it is necessary to keep the time going.

Last edited by scmb1 (2010-07-03 17:07:05)


http://i48.tinypic.com/2z5pqad.png

Offline

 

#9 2010-07-03 17:28:22

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: TImer help

Harakou wrote:

I've tried using this:
http://i45.tinypic.com/2vx2lv6.gif
But it doesn't seem to work. Does anyone know why? (Not that it really matters; the solutions above me work fine.)

I actually tried that, too, before you posted, and it didn't work - and I think scmb1 is right. I tried running it with Flash Blocks and it seemed horribly inaccurate.

Offline

 

Board footer