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

#1 2009-03-10 11:28:27

issi7
Scratcher
Registered: 2009-03-10
Posts: 1

More about variables!!!

How do i change my background as soon as my score (variable) turns 20???
Scratch can be sooo confusing!  sad

Offline

 

#2 2009-03-10 11:45:16

Iris_Sophia
Scratcher
Registered: 2009-03-09
Posts: 19

Re: More about variables!!!

I'm also new to this but I think all you have to do is broadcast a message when your variable turns 20 and program the background to change  when it recieves that message. Hope this helps!

Offline

 

#3 2009-03-10 11:48:54

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: More about variables!!!

broadcast is unessasry. on the background
<when green flag clicked>
<forever>
<if><(  <{VAR  }><=> 20 )>
<switch to background[ what ever you want
<end>
<end>
Scratch is NOT confusing, you just need to look at the code. in word what would you say you want done? if variable is 20 change background, that is exactly what i did except change it a bit to match the scripting

Offline

 

#4 2009-03-10 12:22:11

Iris_Sophia
Scratcher
Registered: 2009-03-09
Posts: 19

Re: More about variables!!!

Maybe a dumb question and easy to test later but if a variable is private to a sprite can the  stage "see" it?

Offline

 

#5 2009-03-10 13:00:57

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: More about variables!!!

Nope. There are a few reasons to use local variables over globals, but they're often more limiting than useful -- when you need to use a local, you'll know it  smile

Offline

 

#6 2009-03-10 13:06:55

Iris_Sophia
Scratcher
Registered: 2009-03-09
Posts: 19

Re: More about variables!!!

Thanks!

Offline

 

#7 2009-03-10 13:11:28

Iris_Sophia
Scratcher
Registered: 2009-03-09
Posts: 19

Re: More about variables!!!

BTY I used to live in Canada, pretty far from you though ( New Brunswick).

Miss the snow.

Hope to upload interesting program soon.

Trying to simulate an editor.

Thanks again!

Offline

 

#8 2009-03-10 13:19:44

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: More about variables!!!

Believe it or not, it snowed here yesterday... Gone now, though, and I can assure you nobody misses it.  smile

Good luck with your projects!

Offline

 

#9 2009-03-10 13:22:50

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

Re: More about variables!!!

Iris_Sophia wrote:

Maybe a dumb question and easy to test later but if a variable is private to a sprite can the  stage "see" it?

Actually, yes it can!  It can use the special Sensing block which reports the values of sprite attributes and local (or private) variables.  Look in the Sensing tab for a block that has two drop-down menus separated by the word "of".  Using this block really increases the usefulness of local sprite-specific variables.  You can look at (but not change) the value of any sprite's local variables from any other sprite or the stage.  In fact, you probably should make most of your variables local unless you really need to be able to change the value from some other sprite.


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

Offline

 

#10 2009-03-10 14:05:31

Iris_Sophia
Scratcher
Registered: 2009-03-09
Posts: 19

Re: More about variables!!!

Appreciate answers.

  mrweston: I miss snow but only some the time LOL.

  Paddle2See: Thanks, I checked  out the Sensing tab.

Offline

 

#11 2009-03-10 15:50:55

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: More about variables!!!

Hey, that's some helpful info, Paddle2See -- thanks for that! Hadn't ever used that block to access variables... I can see how it would make local variables more useful than otherwise. Will be reworking my approaches from now on!  smile

Offline

 

#12 2009-03-13 20:48:43

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Re: More about variables!!!

yambanshee wrote:

Scratch is NOT confusing,

Opinion  tongue

Offline

 

#13 2009-03-13 21:14:08

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

Re: More about variables!!!

Jello715 wrote:

yambanshee wrote:

Scratch is NOT confusing,

Opinion  tongue

Yeah, just try using some real languages then say that. You learn variables in 6th grade math. If you know 6th grade math then you should be able to use scratch without any other programming experience.

Scratch is as easy as it gets.


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

 

#14 2009-03-13 21:32:47

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

Re: More about variables!!!

archmage wrote:

Jello715 wrote:

yambanshee wrote:

Scratch is NOT confusing,

Opinion  tongue

Yeah, just try using some real languages then say that. You learn variables in 6th grade math. If you know 6th grade math then you should be able to use scratch without any other programming experience.

Scratch is as easy as it gets.

QFT!
(haha, bringing back an old tradition)
But yes, you do learn variables in grade six math (or you're supposed to... If you aren't your teacher is forgetting to teach you a life-changing lesson, because by the time you get into G8M, you're going to die if you don't know what a variable is.)

Offline

 

#15 2009-03-13 21:35:17

bosox397
Scratcher
Registered: 2008-02-17
Posts: 1000+

Re: More about variables!!!

coolstuff wrote:

archmage wrote:

Jello715 wrote:


Opinion  tongue

Yeah, just try using some real languages then say that. You learn variables in 6th grade math. If you know 6th grade math then you should be able to use scratch without any other programming experience.

Scratch is as easy as it gets.

QFT!
(haha, bringing back an old tradition)
But yes, you do learn variables in grade six math (or you're supposed to... If you aren't your teacher is forgetting to teach you a life-changing lesson, because by the time you get into G8M, you're going to die if you don't know what a variable is.)

lol we did variables in 4th grade...


Dear Scratch Users,
I'm done with scratch, or at least making projects. I have made one last big game, thats both fun and teaches a lesson about water. It'd mean a lot if you gave me feedback.                              http://scratch.mit.edu/projects/bosox397/569201

Offline

 

Board footer