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

#1 2010-08-22 21:20:12

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

A Secret of Variables In Scratch!

There is a convienent secret to Local Variables to make only a couple of sprites read them!

There is a circle block that looks like this, but an actual BLOCK (  big_smile  )

([v X position] of [v Sprite])
It can read local variables!

I.E. =
Sprite1 has a 'local' variable called (Score)
With the ([x position] of [Sprite]) block,
Sprite2 can read the score by setting the [x position] to ([Score] of [Sprite1])!

That is a cool trick for sharing variables for only certain sprites!

Keep Scratching, Scratchers!

Last edited by bbbeb (2010-08-22 21:21:18)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#2 2010-08-22 21:24:37

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: A Secret of Variables In Scratch!

This block has helped me out numerous times.
big_smile -12three- big_smile

Offline

 

#3 2010-08-22 21:29:08

MasterOfDeception
Scratcher
Registered: 2009-12-29
Posts: 100+

Re: A Secret of Variables In Scratch!

Whoa, I never knew you could do that. COOL!


"My Language Arts teacher beat Chuck Norris up." -12three

Offline

 

#4 2010-08-31 14:27:44

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: A Secret of Variables In Scratch!

I actually just discovered that a couple weeks ago!


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2010-08-31 16:06:17

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: A Secret of Variables In Scratch!

MoreGamesNow wrote:

I actually just discovered that a couple weeks ago!

Same with me!


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#6 2010-08-31 16:17:33

Telemachus
Scratcher
Registered: 2010-04-21
Posts: 500+

Re: A Secret of Variables In Scratch!

Never knew about that! Thanks!


http://i54.tinypic.com/10h0fnp.jpg

Offline

 

#7 2010-08-31 16:21:27

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: A Secret of Variables In Scratch!

I knew this for ages. There is a error however.
make a variable for sprite1 called 'direction'.
Set it to hacked.
Then use the (|direction| of |Sprite1|). Use the one refering to the direction of Sprite1 e.g 90.

It will report your local variable, eg 'hacked'!


You can now reach me on Twitter @johnnydean1_

Offline

 

#8 2010-08-31 16:58:21

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: A Secret of Variables In Scratch!

I knew this a long time again. But thanks for posting this.  smile


Hai.

Offline

 

#9 2010-08-31 17:15:23

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

Re: A Secret of Variables In Scratch!

I never knew about that! I always thought that local variables were just that... local variables. Thanks a bunch!

Offline

 

#10 2010-08-31 18:48:26

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: A Secret of Variables In Scratch!

O_O I'll be sure to remember that!  big_smile


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#11 2010-08-31 18:59:28

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: A Secret of Variables In Scratch!

johnnydean1 wrote:

I knew this for ages. There is a error however.
make a variable for sprite1 called 'direction'.
Set it to hacked.
Then use the (|direction| of |Sprite1|). Use the one refering to the direction of Sprite1 e.g 90.

It will report your local variable, eg 'hacked'!

It doesn't do that for me...


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#12 2010-08-31 19:09:38

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: A Secret of Variables In Scratch!

Awesome! I never knew that!!  yikes

ScratchReallyROCKS wrote:

johnnydean1 wrote:

I knew this for ages. There is a error however.
make a variable for sprite1 called 'direction'.
Set it to hacked.
Then use the (|direction| of |Sprite1|). Use the one refering to the direction of Sprite1 e.g 90.

It will report your local variable, eg 'hacked'!

It doesn't do that for me...

It works; I've done it for confusing x & y positions in a certain project.  big_smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#13 2010-08-31 20:08:13

laser100
Scratcher
Registered: 2009-12-04
Posts: 100+

Re: A Secret of Variables In Scratch!

I knew it because i downloaded one of archmage's projects, and it used this!

Last edited by laser100 (2010-08-31 20:08:24)

Offline

 

#14 2010-09-01 22:07:19

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: A Secret of Variables In Scratch!

This is a cool feature.

@johnnydean1: why do we want to know about errors again?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#15 2010-09-01 22:26:19

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: A Secret of Variables In Scratch!

bbbeb wrote:

@johnnydean1: why do we want to know about errors again?

'Cuz they're fun.  tongue

And thanks for posting this! I never knew that. It'll save me if I accidentally do a bunch of programming with a local variable that was supposed to be global.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer