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

#51 2008-11-30 10:40:53

sonicfan2
Scratcher
Registered: 2008-11-30
Posts: 2

Re: How can I learn about Variables?

I am Sonicfan2,i only have one friend, Sonicfan



___________________________________________________________________________________
THIS IS A MUST-SEE WEBSITE

http://thesecretshow.com

Offline

 

#52 2008-11-30 10:43:00

sonicfan2
Scratcher
Registered: 2008-11-30
Posts: 2

Re: How can I learn about Variables?

plz see!

http://thesecretshow.com

Offline

 

#53 2008-12-14 17:21:23

GoldenAxe
Scratcher
Registered: 2008-12-10
Posts: 48

Re: How can I learn about Variables?

You learned me something! I didn't know!

Offline

 

#54 2009-01-05 11:54:41

pokemon_master12
Scratcher
Registered: 2008-09-26
Posts: 100+

Re: How can I learn about Variables?

You can use variables to keep track of how many of something you've done, like your score, how many items you've collected, how many things are left to be done, etc. But you can also use words in variables instead of numbers, like, for example, you could make a variable called "animal", in a pet game, and make some animal sprites. Say there were 3 sprites: a dog, a cat, and a horse. If you clicked the horse, the variable: "animal" would change from "none" to "horse", instead of "1" to "2" or "3" or whatever. There is also a very clever way of using words in variables to type your name, which Paddle2See discovered. Just look at his/her stuff and you'll find the project.
You make a variable called "Uppercase" and a list called "text input". You use this script for typing in letters:

[blocks]<when[ a ]key pressed>[/blocks]
[blocks]<if>[/blocks][blocks]<( [blocks]<{ Uppercase }>[/blocks] <=> 1 )>[/blocks]
add A to text input
[blocks]<else>[blocks]
add a to text input
[blocks]<end>[/blocks]

And this script to for the "Uppercase" variable (which you can add to any sprite) to add uppercase letters whilst typing:

<when[ up arrow ]key pressed>
[blocks]<set{ Uppercase }to( [/blocks] [blocks](( 1 <-> [blocks]<{  Uppercase }>[/blocks] ))[/blocks]

So you can use variables for all sorts of things! I hope this helps you! If it doesn't, just let me know by posting a comment in my topic: "Anyone Need Any Help?" in the All About Scratch section!
Happy Scratch-ing!  smile


My Dragon Egg! http://dragcave.net/image/5YUA.gif
Visit my blog: http://freyasworld.wordpress.com/

Offline

 

#55 2009-01-06 17:05:23

ryan11
Scratcher
Registered: 2008-10-02
Posts: 6

Re: How can I learn about Variables?

i am not sure about variables so if you can tell me can you do it asap

Offline

 

#56 2009-01-29 09:12:52

zbs
Scratcher
Registered: 2008-06-08
Posts: 4

Re: How can I learn about Variables?

Wow, Super Smash Bros. Scratch is REALLY good!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 10/10

Offline

 

#57 2009-01-29 10:24:59

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

Re: How can I learn about Variables?

zbs wrote:

Wow, Super Smash Bros. Scratch is REALLY good!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 10/10

Hey zbs, this post of yours doesn't seem to have anything to do with the topic being discussed (Variables).  Please put your posts only on related topics.  You can also start a new topic if you can't find one.  Thanks.


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

Offline

 

#58 2009-01-31 03:45:21

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: How can I learn about Variables?

Variables can also be used to show messages. For example:

[blocks]<when I receive[ play
<if><( <{ level  }> <=> 1 )>
<set{ message  }to( Get to the door to go to the next level.
<end>
<if><( <{ level  }> <=> 2 )>
<set{ message  }to( If you touch a spike, then you have to restart the level.
<end>
<if><( <{ level  }> <=> 3 )>
<set{ message  }to( You need to press buttons to open doors.
<end>

Last edited by floppy_gunk (2009-01-31 03:46:24)


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#59 2009-03-03 20:42:13

yoltanya
Scratcher
Registered: 2009-02-06
Posts: 1

Re: How can I learn about Variables?

I am learning that variables play an important part in programming. Assigning variables is a essential way of communicating to the program as to what you want it to do.  For instance, if I wanted to keep up with my students' weight using the scratch program, I would use "weight" as the variable.

Offline

 

#60 2009-03-31 05:25:37

Rolers_sonic_tails
Scratcher
Registered: 2008-07-19
Posts: 87

Re: How can I learn about Variables?

a variable like <{ goals scored }>?


http://planetsmilies.net/cool-smiley-8942.gif
cool! click the color-changing people to go to where i found it!

Offline

 

#61 2009-03-31 05:26:39

Rolers_sonic_tails
Scratcher
Registered: 2008-07-19
Posts: 87

Re: How can I learn about Variables?

<stop all sounds> <play note( 234231313 )for( 9999999999999999999999 )secs> that is alot


http://planetsmilies.net/cool-smiley-8942.gif
cool! click the color-changing people to go to where i found it!

Offline

 

#62 2009-03-31 05:29:31

Rolers_sonic_tails
Scratcher
Registered: 2008-07-19
Posts: 87

Re: How can I learn about Variables?

sonicfan2 is me and has no signiture ok?


http://planetsmilies.net/cool-smiley-8942.gif
cool! click the color-changing people to go to where i found it!

Offline

 

#63 2009-03-31 07:41:32

Rolers_sonic_tails
Scratcher
Registered: 2008-07-19
Posts: 87

Re: How can I learn about Variables?

Ok now will i get that signiture


http://planetsmilies.net/cool-smiley-8942.gif
cool! click the color-changing people to go to where i found it!

Offline

 

#64 2009-04-03 14:56:11

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: How can I learn about Variables?

I've used it for cpus in my game i'm about to upload ( tongue )

<{ X of sprite }>
<{ Y of sprite }>

I would explain cpus but it's another story...

<set{ X of sprite }to(<x position>       

Then the enemy
<when green flag clicked>
<forever>
<glide( Number of seconds )secs to x sad  <{ X of sprite }> )y sad  Y of sprite

sorry if i went off topic there but it included variables about cpus


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

#65 2009-04-04 10:15:35

piko_12
Scratcher
Registered: 2009-03-15
Posts: 37

Re: How can I learn about Variables?

Does anyone knows how 'velocity' variable works ??

Offline

 

#66 2009-04-04 10:51:01

golfer3
Scratcher
Registered: 2008-11-02
Posts: 1000+

Re: How can I learn about Variables?

piko_12 wrote:

Does anyone knows how 'velocity' variable works ??

its really quite easy. just search for like velocity tutorial. i could show u but some tutorials are easier and faster

Offline

 

#67 2009-04-20 13:22:31

piko_12
Scratcher
Registered: 2009-03-15
Posts: 37

Re: How can I learn about Variables?

golfer3 wrote:

piko_12 wrote:

Does anyone knows how 'velocity' variable works ??

its really quite easy. just search for like velocity tutorial. i could show u but some tutorials are easier and faster

Thank you, golfer3. Where can i find the tutorial?
Thank you again  smile
                                                                Piko_12

Offline

 

#68 2009-04-20 13:56:56

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: How can I learn about Variables?

piko_12 wrote:

golfer3 wrote:

piko_12 wrote:

Does anyone knows how 'velocity' variable works ??

its really quite easy. just search for like velocity tutorial. i could show u but some tutorials are easier and faster

Thank you, golfer3. Where can i find the tutorial?
Thank you again  smile
                                                                Piko_12

"Velocity" is just the name of a variable, just because it is named velocity doesn't make a difference.
However, if you want to know how to use velocity in one of your games I can help.
    Let's start with "Y Velocity":
Using yVelocity will help if you want to make good jumping scripts for your games.
To start this session of testing arrange the stage like this:
http://img144.imageshack.us/my.php?image=stage.gif
If the image doesn't load go to this link: http://img144.imageshack.us/my.php?image=stage.gif
Then in the Cat sprite make this script:
http://img519.imageshack.us/my.php?image=picture4kef.png
If the image doesn't load go to this link: http://img519.imageshack.us/my.php?image=picture4kef.png
Text of the comment block (if you can't read it):
This is a basic jumping script. We'll start by breaking it down. The first if statement with the set yVelocity to 0 block in it is their so the cat will not fall through the ground. The next if with the set yVelocity to 15 block in it will function if the cat is on the ground and the up arrow is pressed and will make the cat jump.
Out of that set of ifs the change y by yVelocity will make him fall or rise depending on the velocity variable. And the change yVelocity by -1 is gravity.

Remember that you can change the 15 in the;
http://img406.imageshack.us/img406/8998/picture5a.png
block to make the cat jump higher!
HERE IS THE LINK TO THE FORUM TOPIC http://scratch.mit.edu/forums/viewtopic.php?id=16077

Last edited by demosthenes (2009-04-20 14:18:51)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#69 2009-04-20 14:00:20

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: How can I learn about Variables?

piko_12 wrote:

Does anyone knows how 'velocity' variable works ??

Names of variables are not important. The role of variables is what counts.

velocity refers to speed


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#70 2009-05-07 13:07:04

pokemon_master12
Scratcher
Registered: 2008-09-26
Posts: 100+

Re: How can I learn about Variables?

This topic is getting a little all over the place now...

Anyway, as I said, variables can be set to words as well as numbers. You just wouldn't be able to put "if mood=happy" because in the equals block, you can only type numbers, not letters. Variables don't always have to be "if this variable equals this, make this message appear or this screen appear", they can also determine how fast the sprite goes, whether it gets more power or an extra attack move if it reaches a certain score/level, or even what it randomly says or does! Variables are very useful indeed. Your forum topic actually just made me remember that! I haven't used variables in clever ways like that in a while...  big_smile


My Dragon Egg! http://dragcave.net/image/5YUA.gif
Visit my blog: http://freyasworld.wordpress.com/

Offline

 

#71 2009-05-08 09:21:58

nlittle15
Scratcher
Registered: 2009-02-14
Posts: 2

Re: How can I learn about Variables?

<when[  ]key pressed><forever><if><key[  ]pressed?><move(  )steps>

Offline

 

#72 2009-06-07 14:24:34

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How can I learn about Variables?

All you need to know about a variable:
1. It is treated as a number. Say we have a variable called pie. We use a block to set Pie to 5. 5 divided by pie is the same as 5 divided by 5.
2. Names don't matter. The name helps you remember it, calling a variable **** is the same as calling it bob.
3. Anything that's not just a number will be treated as 0. Say we set variable bob to pie. bob equals 0.
4. Lists are better. A list is basically a bunch of variables. You can use 1 list instead of 200+ variables in a project. You just need to remember which variable is which number...
5. You can <broadcast[ <{ variable }>

That's pretty much it.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#73 2009-06-07 14:26:52

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How can I learn about Variables?

pokemon_master12 wrote:

Variables are very useful indeed.

Lists are better.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#74 2009-06-12 18:15:22

SpiritOfDarkrai
Scratcher
Registered: 2009-06-12
Posts: 2

Re: How can I learn about Variables?

I need help with variables!

I can't get my Character's broadcasted "Level Up" to be recieved and activate the "Change Level by 1" Variable doodamabob thing.

Offline

 

#75 2009-07-01 19:03:16

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: How can I learn about Variables?

.::ADVANCED VARIABLE HELP::.

If you already know how to use variables, you might find these helpful.

If you right click (windows) or ctrl click (mac) on a variable, you a menu will pop up. I has four options.

1. Normal Readout: When you create a variable, this is the default veiw.
2. Large Readout: This is a larger display of the variable, but the variable name is hidden
3. Slider: This creates a slider that a user can change. It shows the name of the variable and the value of the variable. The default range is 0-100
4. Hide: A shortcut that hides the variable

If you change your variable to a slider, a new option appears:

Set Slider Min and Max: If you click this option, a window pops up. You can now set the minimum and maximum. The minium does not have to be 0. Click OK to continue.

Hope that helps


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

Board footer