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.
Offline
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.
Offline
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.
Offline
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.
Offline
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)
Offline
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...
Offline
Offline
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) endNot 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.
Offline
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) endNot 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
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.
Offline
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
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.
Offline