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

#51 2008-01-07 21:36:42

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

Heybrian wrote:

i dont get your post at ALL.  =P

i was tlaking about something in a different thread that Kevin pointed out to me


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#52 2008-01-07 23:33:45

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

I have the same ability to contact the Scratch team that you all do.  They read the forum, and they read mail sent to scratch-feedback@media.mit.edu

As for long scripts, they don't slow things down at all.  What matters is how many blocks are being executed at once, not how many are sitting around doing nothing at the moment.

The difference between  "forever if <x>" as a single block and "forever" "if <x>" is that it is possible to implement the "forever if <x>"  as "forever" "wait for <x>" and it is possible for "wait for <x>" to be evaluated only when one of the variables involved in <x> are changed.  I don't know exactly how the "wait for <x>" is implemented in Scratch (perhaps Jens could look through the source code?), but if it is done in the most efficient way the "forever if <x>" construct could be substantially faster than "forever" "if <x>".

Offline

 

#53 2008-01-08 16:33:37

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

kevin_karplus wrote:

The difference between  "forever if <x>" as a single block and "forever" "if <x>" is that it is possible to implement the "forever if <x>"  as "forever" "wait for <x>"

ok... so "forever if <x>" is the same as "forever" "wait for <x>"? i dont understand


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#54 2008-01-08 20:35:55

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

kevin_karplus wrote:

The difference between  "forever if <x>" as a single block and "forever" "if <x>" is that it is possible to implement the "forever if <x>"  as "forever" "wait for <x>" and it is possible for "wait for <x>" to be evaluated only when one of the variables involved in <x> are changed.  I don't know exactly how the "wait for <x>" is implemented in Scratch (perhaps Jens could look through the source code?), but if it is done in the most efficient way the "forever if <x>" construct could be substantially faster than "forever" "if <x>".

I dont understand either/


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#55 2008-01-08 20:36:56

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

funkymonkey wrote:

Heybrian wrote:

i dont get your post at ALL.  =P

i was tlaking about something in a different thread that Kevin pointed out to me

oh. that makes more sense.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#56 2008-01-09 11:13:40

pasta3049
Scratcher
Registered: 2007-10-18
Posts: 31

Re: A recieve sensing block

[blocks]<forever if> condition
<end>[/blocks]

can be implemented as

[blocks]<forever>
<wait until> condition
<end>
[/blocks]

Last edited by pasta3049 (2008-01-09 11:15:17)

Offline

 

#57 2008-01-09 18:42:17

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

pasta3049 wrote:

[blocks]<forever if> condition
<end>[/blocks]

can be implemented as

[blocks]<forever>
<wait until> condition
<end>
[/blocks]

how do you get in those extra words


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#58 2008-01-09 19:17:32

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

pasta3049 wrote:

[blocks]<forever if> condition
<end>[/blocks]

can be implemented as

[blocks]<forever>
<wait until> condition
<end>
[/blocks]

ok, i get it now. so Kevin was saying how the wait untill block makes it slower. that makes since


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#59 2008-01-09 19:27:01

MITscratcher
Scratcher
Registered: 2007-09-16
Posts: 100+

Re: A recieve sensing block

I agree in  a way that you a receive sensing block would make things more convenient, but you can do just the same + more with variables.


http://scratch.mit.edu/projects/MITscratcher/235497
                    ^ My NEW Snake Game! ^

Offline

 

#60 2008-01-09 19:41:40

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

MITscratcher, you have it backwards.  The "wait until" block has the potential to have less impact on the computer than an "if block" since it only needs to be evaluated when any of the variables it is looking at changes, while an if block would keep getting tested over and over.

Offline

 

#61 2008-01-09 20:49:20

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

but you can only do it someways with variables. i know i did it like that on my scratch cat adventures but the sensing block can be used for more, considering thats not the job for variables.


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#62 2008-01-10 13:57:06

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

Anything that can be done with "wait until I receive" could be done with variables also.
Some of the other uses proposed for <I receive> (in "if" or "repeat until") might not be easy to do with variables, but they might also be hard to implement in the underlying scratch interpreter, also.

Offline

 

#63 2008-01-10 16:49:46

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

the point is, some people fin it to hard to do it with variables, and they want an "i recieve" sensing block to make it easier for the


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#64 2008-01-10 17:46:56

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

Oh, I agree that a "wait until I receive" command would be very nice to have.  It just isn't quite as easy to implement as most of the other suggestions made here, and a lot of what it is wanted for can be done (albeit clumsily) with the existing commands of scratch.

Offline

 

#65 2008-01-10 20:23:26

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

but as you earlier said. or someone said. global variables make it lag, and you may need global variables to do global broadcasting


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#66 2008-01-10 21:09:55

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

Global variables do not slow down programs, though a busy-wait loop (using an "if" inside a forever block, instead of waiting for a condition on the variable) can slow a project down a lot.

Offline

 

#67 2008-01-10 22:20:06

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

and i do that all the time. would a forever if block work better?


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#68 2008-01-11 10:45:40

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

If properly implemented, a "forever if" block should put less load on the computer than forever and if separately, since it translates to
   forever
      wait until <condition>
      ....
and "wait until" can be implemented to use less CPU resources than "if".  I don't know whether the Squeak or java implementations of scratch actually do implement "wait until" efficiently, or if they use inefficient busy waiting.

Offline

 

#69 2008-01-12 00:32:17

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

o ho. i always never used that on my first projects. od just do forever
                                                                                           if


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#70 2008-01-12 01:29:54

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: A recieve sensing block

Heyb,
Making variables Global doesn't cause a "lag" issue; Making every variable in the project a global would be perfectly OK as far as the computer is concerned, because what humans call a variable is just a storage location as far as the computer is concerned.  The problem with Global variables is that any script in any sprite can not only read the variable, but can also change it.

Suppose a programmer was working on a big project and decided to add "damage" to a Sprite.  He (or she) could make a Global variable named "Hero_Health", and add a script to the "Enemy":

If touching <"Hero">
   change Hero_Health by -1

Then, the programmer has to stop Scratching to eat dinner, do homework or whatever.  When returning to the project a day later, he may forget that the Enemy already can damage the Hero, and add a script to the "Hero":

If touching <"Enemy">
   change Hero_Health by -1

This is a simple example, but shows why Global variables should be limited.  It isn't the computer that gets confused (computers don't get confused!), the problem is that Global variables can confuse the programmer.

By making a variable Local ("for this sprite only"), you keep any other sprite from being able to change it.  Local variables "belong" to their "Sprite", other sprites can sense the variable's value (the number it stores), but they can't change it.  In the example, the Enemy could sense the Hero's health, but only the Hero could change the variable.

This makes your job easier, especially as the project grows and lots of variables are needed to store (and change) information.  Keeping variables local makes it easier to find the problem if a variable is changing in a way the programmer didn't expect.

-MrEd

Offline

 

#71 2008-01-12 09:16:02

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

that makes since. but what if you make a local variable, then later you realize that you need it for 2 or more sprites, but it is already local?


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#72 2008-01-12 15:04:37

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

Changing variables from local to global in scratch is not currently possible. You have to create a new variable and find every instance of the old one and change it.  This is incredibly difficulty and time-consuming in scratch (since each set block has to be dragged out and a new one dragged in, and there is no search capability).  That is why the suggestion is often made to provide a way for changing whether a particular variable is global or local, or for renaming a variable (which is equally difficult to do in the current version of scratch).

Offline

 

#73 2008-01-13 18:14:04

Heybrian
Scratcher
Registered: 2007-12-05
Posts: 100+

Re: A recieve sensing block

yeah so its better to use global ones?


Black Mesa. go here to get a game 10 times better than SN or FW.  http://scratch.mit.edu/galleries/view/10650
Smiley! copy and paste these into your post or signature!  smile   sad    yikes                 big_smile     wink    tongue    hmm    neutral   cool   lol   mad   roll

Offline

 

#74 2008-01-13 19:26:28

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: A recieve sensing block

No, neither local nor global is "better", but they are different. 

Local variables can only be changed by one sprite.  This makes debugging easier and keeps variables organized.  For example, it is much easier to have a "health" variable for each sprite that the sprite keeps track of, than to have large numbers of global variables.

Global variables can be changed by any sprite.  This makes them useful for inter-sprite communication, where one sprite sets the variable, then does a broadcast to let the other sprites know.

Both types of variables are useful, but in different ways.

Offline

 

#75 2008-01-13 19:41:24

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: A recieve sensing block

kevin_karplus wrote:

Changing variables from local to global in scratch is not currently possible.

i know. thats the problem. maybe it should be added into the next version of scratch?


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

Board footer