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

#1 2012-10-26 11:10:12

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

A number that decreases as the timer increases

I need a script that gives me a number, and the bigger the timer is, the smaller the number gets, and the smaller the number gets, the smaller the decrement.
Eg. After 1 second my number is 20, after 5 seconds it is 18, after 10 seconds the number is 17 ect.

Note that the number cannot go below 0.

Was that clear?

Last edited by Splodgey (2012-10-26 11:28:05)

Offline

 

#2 2012-10-26 11:13:58

meew0
Scratcher
Registered: 2010-02-22
Posts: 1000+

Re: A number that decreases as the timer increases

when gf clicked
repeat until <(number) = (0)>
set [number v] to ((21) - (timer))
end

Last edited by meew0 (2012-10-26 11:14:17)


http://i.imgur.com/mJV3j.pnghttp://i.imgur.com/HwWAX.pnghttp://i.imgur.com/sZ7Ui.pnghttp://i.imgur.com/0y6yh.pnghttp://i.imgur.com/nOC4l.png

Offline

 

#3 2012-10-26 11:15:23

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: A number that decreases as the timer increases

when gf clicked
forever
   set [myVar v] to ((20) - (timer))
   if <(myVar) < (0)>
      set [myVar v] to (0)
   end
end

Last edited by BoltBait (2012-10-26 11:16:03)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#4 2012-10-26 11:27:40

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: A number that decreases as the timer increases

BoltBait wrote:

when gf clicked
forever
   set [myVar v] to ((20) - (timer))
   if <(myVar) < (0)>
      set [myVar v] to (0)
   end
end

I knew someone would say that, divided by is much better since it wouldn't go below 0. The point is, the smaller it gets, the smaller the decrement, that, decreases by 1 every second, and the decrement stays the same.


meew0 wrote:

when gf clicked
repeat until <(number) = (0)>
set [number v] to ((21) - (timer))
end

That is even worse, I didn't say I wanted it to stop at 0, I said It can't go below 0.

Last edited by Splodgey (2012-10-26 11:30:32)

Offline

 

#5 2012-10-26 11:32:30

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: A number that decreases as the timer increases

when gf clicked
forever
set [number v] to ((1) / (timer))
end
?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#6 2012-10-26 11:39:53

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: A number that decreases as the timer increases

MathWizz wrote:

when gf clicked
forever
set [number v] to ((1) / (timer))
end
?

I just facepalmed so hard it hurt, not at you, at myself.... THAT WAS SO OBVIOUS!!! I even considered divided by....  hmm


Wait, I need something that doesn't decrease quite so rapidly.

Last edited by Splodgey (2012-10-26 11:43:28)

Offline

 

#7 2012-10-26 12:00:22

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: A number that decreases as the timer increases

Ok, Nevermind, I've worked it out:

(((32) + ((timer) * (8))) / (timer))

Offline

 

#8 2012-10-26 13:43:35

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: A number that decreases as the timer increases

Closed by request.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer