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

#1 2011-07-03 09:13:14

uglidoll
New Scratcher
Registered: 2010-11-19
Posts: 8

how do variables work?

i have no idea how they work.
will someone tell me?

Offline

 

#2 2011-07-03 09:29:57

jslomba
Scratcher
Registered: 2009-09-25
Posts: 1000+

Re: how do variables work?

variables are just numbers that scratch keeps track of. the value of the variable is stored. in the oval shaped block. you can fit that inside any spot where a number goes.

Last edited by jslomba (2011-07-03 09:31:01)


the the the the the

Offline

 

#3 2011-07-03 10:25:44

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: how do variables work?

That's kinda right, but Variables don't store just numbers(Unless you're talking about what the computer reads). They can store any data you want! How do you like that?  To use them, first make a new variable, second go to the set variable  or change variable by blocks and type in what you want. I hope you have fun!

Offline

 

#4 2011-07-03 10:25:52

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: how do variables work?

jslomba wrote:

variables are just numbers that scratch keeps track of. the value of the variable is stored. in the oval shaped block. you can fit that inside any spot where a number goes.

A variable can actually be any value, not just a number.  wink
Variable on the Scratch Wiki.

Offline

 

#5 2011-07-03 14:33:07

laserPrototypes
New Scratcher
Registered: 2011-07-03
Posts: 2

Re: how do variables work?

A variable is a value that can change in the program. You can use a variable for a score, for example, because score changes.

Offline

 

#6 2011-07-03 15:33:44

LordAwesome123
Scratcher
Registered: 2011-01-18
Posts: 100+

Re: how do variables work?

Variables can be used for alot of diffrent things. For example: You are playing a game where a moving thin line is moving fast around the screen.  Here is an example of what could happen when the variable is clicked:

<when green flag clicked>
<wait until> <mouse down?><<  <and>  >><touching[ Mouse Pointer
<set{ Game Win }to( 1

<when green flag clicked>
<set{ Game Win }to( 0
<wait until> <{ Game Win }> <(  <=>  )> 0
<stop all>

If you cant read that sorry and here is the script in text version:

When flag is clicked
Wait untill Touching mouse pointer and mouse down
Set game win to 1

When flag is clicked
Set game win to 0
Wait untill game win = 1
Stop All

So how it works? Sure you could have just brodcasted that the line was clicked on insted of using all this variable stuff but this is just an alt. way.

Understand?  big_smile


http://i672.photobucket.com/albums/vv82/coke457/cooltext538978807.png
When life gives you lemons... take them... free stuff is cool  smile

Offline

 

Board footer