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

#1 2009-04-30 18:03:06

lcb01
Scratcher
Registered: 2009-04-21
Posts: 4

Help!!!!!

How do you make a Variable = 1-to-100 and then, if Touching a sprite while you push a button, make the variable go back to 0  - no matter what number it was originally from 1 to 100?

Offline

 

#2 2009-04-30 18:34:03

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: Help!!!!!

Use this script to set the variable:

(when event happens)
<set{ variabe }to( <pick random( 1 )to( 100
[/blocks]That randomizes the variable. Then to reset the variable:

(when event happens)
<if><touching[ sprite
<if><key[ (what you want) ]pressed?>
  <set{ variable }to( 0
<end>
<end>[/blocks]


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#3 2009-04-30 18:39:17

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

Re: Help!!!!!

Something like this, maybe?

[blocks]
<when green flag clicked>
<set{ SomeVariable }to( <pick random( 1 )to(  100
<forever if>  << <touching[ SomeSprite  <and> <key[ SomeKey ]pressed?> >>
     <set{ SomeVariable }to( 0
<end>
[/blocks]


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

Offline

 

Board footer