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

#1 2012-08-02 15:33:55

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Anchors in scripts

It would be kind of neat to be able to do this.

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
change size by (5)
change [ghost v] effect by (-5)
end
anchor [anchor1 v]
repeat (10)
change [color v] effect by (2)
end
forever if <key [space v] pressed?>
jump to anchor [anchor1 v]
Basically when an anchor is placed, by using "jump to anchor" you can move backwards in a script. In the example it would cause additional color effects to be applied to the sprite. Anchors would be specific to each script.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#2 2012-08-02 15:36:29

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: Anchors in scripts

'Course, you can use if blocks, but I support.


http://i47.tinypic.com/2iaa73k.png

Offline

 

#3 2012-08-02 15:40:39

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Anchors in scripts

berberberber wrote:

'Course, you can use if blocks, but I support.

thats true but in some instances it is overly cumbersome, and it would also allow many broadcasts to be worked around and placed in one compact script.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#4 2012-08-02 15:50:14

Seil
Scratcher
Registered: 2011-09-02
Posts: 100+

Re: Anchors in scripts

That's a pretty good idea.
In this case, though, you could just duplicate the same color effect repeat portion in the forever if block. This sort of thing has happened in my WIP projects and that's what I did. However, that would take up quite some space, especially if it's a big portion of the script.

I support, this would be a very convenient feature.


http://legacy-cdn.smosh.com/smosh-pit/022011/spongebob-gif-lol.gif

Offline

 

#5 2012-08-02 16:03:26

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Anchors in scripts

I like the script because it would have saved me a bunch of broadcasts in my Chalkboard Pac-Man game, as well as the project I'm working on right now.

I give my support.


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2012-08-03 02:43:54

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Anchors in scripts

don't support. This is basicly a GOTO command, which was dropped from programming languages long ago with good reason: it makes programs look messy and unstructured. Any function involving a GOTO command can be re-written using repeat, repeat until, if, and if/else. This could be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
forever
repeat (10)
  change [colour v] effect by (2)
end
wait until <key [space v] pressed?>
They could also be re-written using broadcasts, as so:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
broadcast [colour effect v]
when i receive [colour effect v]
repeat (10)
change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
broadcast [colour effect v]
or, this particular script (and scripts involving GOTO that follow this pattern) can be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
repeat (10)
  change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
repeat (10)
  change [colour v] effect by (2)
end

Last edited by joefarebrother (2012-08-03 02:45:25)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#7 2012-08-03 06:01:40

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Anchors in scripts

joefarebrother wrote:

don't support. This is basicly a GOTO command, which was dropped from programming languages long ago with good reason: it makes programs look messy and unstructured. Any function involving a GOTO command can be re-written using repeat, repeat until, if, and if/else. This could be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
forever
repeat (10)
  change [colour v] effect by (2)
end
wait until <key [space v] pressed?>
They could also be re-written using broadcasts, as so:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
broadcast [colour effect v]
when i receive [colour effect v]
repeat (10)
change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
broadcast [colour effect v]
or, this particular script (and scripts involving GOTO that follow this pattern) can be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
repeat (10)
  change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
repeat (10)
  change [colour v] effect by (2)
end

Not for 1s1s...


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#8 2012-08-03 08:00:37

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Anchors in scripts


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#9 2012-08-05 05:35:18

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Anchors in scripts

jontmy00 wrote:

joefarebrother wrote:

don't support. This is basicly a GOTO command, which was dropped from programming languages long ago with good reason: it makes programs look messy and unstructured. Any function involving a GOTO command can be re-written using repeat, repeat until, if, and if/else. This could be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
forever
repeat (10)
  change [colour v] effect by (2)
end
wait until <key [space v] pressed?>
They could also be re-written using broadcasts, as so:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
broadcast [colour effect v]
when i receive [colour effect v]
repeat (10)
change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
broadcast [colour effect v]
or, this particular script (and scripts involving GOTO that follow this pattern) can be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
repeat (10)
  change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
repeat (10)
  change [colour v] effect by (2)
end

Not for 1s1s...

It's only the broadcast workaround that requires more than one script. The other workarounds work too without breaking the script. Any script involving GOTO can be worked around using the c-blocks: if, if/else, repeat, repeat until, forever & forever if.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#10 2012-08-05 12:23:20

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Anchors in scripts

joefarebrother wrote:

jontmy00 wrote:

joefarebrother wrote:

don't support. This is basicly a GOTO command, which was dropped from programming languages long ago with good reason: it makes programs look messy and unstructured. Any function involving a GOTO command can be re-written using repeat, repeat until, if, and if/else. This could be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
forever
repeat (10)
  change [colour v] effect by (2)
end
wait until <key [space v] pressed?>
They could also be re-written using broadcasts, as so:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
broadcast [colour effect v]
when i receive [colour effect v]
repeat (10)
change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
broadcast [colour effect v]
or, this particular script (and scripts involving GOTO that follow this pattern) can be re-written as:

when gf clicked
set size to (50)%
set [ghost v] effect to (50)
repeat (10)
  change size by (5)
  change [ghost v] effect by (-5)
end
repeat (10)
  change [colour v] effect by (2)
end
forever if <key [space v] pressed?>
repeat (10)
  change [colour v] effect by (2)
end

Not for 1s1s...

It's only the broadcast workaround that requires more than one script. The other workarounds work too without breaking the script. Any script involving GOTO can be worked around using the c-blocks: if, if/else, repeat, repeat until, forever & forever if.

But the repeat blocks have built in delays, which is undesirable in a very large amount of scripts. I support, this would be useful. We could use this in conjunction with variables to have atomic repeats. You can unroll a loop, but with more advanced things when you do it'll become way to long.

Last edited by zubblewu (2012-08-05 12:24:27)


........................................................................................................................................................................................................................................

Offline

 

#11 2012-08-05 13:52:35

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Anchors in scripts

zubblewu wrote:

joefarebrother wrote:

jontmy00 wrote:


Not for 1s1s...

It's only the broadcast workaround that requires more than one script. The other workarounds work too without breaking the script. Any script involving GOTO can be worked around using the c-blocks: if, if/else, repeat, repeat until, forever & forever if.

But the repeat blocks have built in delays, which is undesirable in a very large amount of scripts. I support, this would be useful. We could use this in conjunction with variables to have atomic repeats. You can unroll a loop, but with more advanced things when you do it'll become way to long.

There's also the broadcast workaround. Your project doesn't HAVE to be 1s1s, you know.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#12 2012-08-05 14:33:21

pizza22
Scratcher
Registered: 2012-04-30
Posts: 500+

Re: Anchors in scripts

This would be quite helpful, at school in electronics we change the programming for a steady hand game, to alter the music at the end and the number of tries you get. That had Go To, which is practicly like this anchor.

Offline

 

#13 2012-08-05 17:37:35

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Anchors in scripts

Look, GOTO is for low-level machine language. High-level languages like scratch have if, if/else, repeat, repeat until, and forever. That is all that is needed to work around any GOTO command.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

Board footer