# When green flag clicked different behavior

I noticed a different behavior between Snap and Scratch when the green flag is clicked.

In Scratch, clicking the green flag stops all scripts and then restart the scripts starting with "WHEN green flag CLICKED". You can see it at https://scratch.mit.edu/projects/410789669/, where you have to press the space key in order to make the sprite rotate and glide after you click the green flag.

In Snap instead, clicking the green flag does not stop all scripts before restarting the scripts that starts with "WHEN green flag CLICKED". You can see it at https://snap.berkeley.edu/snap/snap.html#present:Username=s_federici&ProjectName=glide%20and%20rotate%20after%20space%20key, where, after you press the space key, the sprite keeps gliding even before you press the space key. In order to get the same behavior as in Scratch, you have to stop the project first, by clicking the STOP button, and then restart it by clicking the green flag.

Is this a wanted behavior in Snap? If so, is there a clever way of using the STOP block in order to add a single script (or to add a script to all sprites) that will make the green flag work exactly as in Scratch?

here's a way to do that

you just need to have all when flag clicked blocks blocks (except this one) be when I receive [start project v] or whatever you want the message to be.

Thanks.

Looking at the script I had hoped Snap had a "secret" message to start the projects

__shout__go__ is the same as hitting the green flag

you can also shift click the input and there's a green flag (if you make a message called __shout__go__ it'll show up as a green flag)

Both suggestions had an effect, but the project https://snap.berkeley.edu/snap/snap.html#present:Username=s_federici&ProjectName=glide%20and%20rotate%20after%20space%20key still does not work as I would expect.

the __shout__go__ message basically presses the green flag using code, so all when flag clicked hat blocks run. Here's the fixed project.

I'm guessing you want to get rid of the second "green flag" script and just add the "stop all but this script" block to the original one:

This does what you want, right?

Yes, now the project has the same behavior it has in Scratch. But what I want, if possible, is a separate script to add to a single sprite -or to all sprites- so that the original Snap project (that I restored at https://snap.berkeley.edu/snap/snap.html#present:Username=s_federici&ProjectName=glide%20and%20rotate%20after%20space%20key) will work as the original Scratch project with the same scripts (that is https://scratch.mit.edu/projects/410789669/) without modifying the original scripts.

Snap says that it cannot fetch the project as the project does not exist?

woops, forgot to share it, lol

edit: it should be shared now

Thanks a lot, that should work. When I shift-clicked the menu and selected the green flag I got a "green flag clicked" message that didn't work. How did you get the "green flag" message? You just wrote "green flag"?

yeah, it's a normal message

I guess I have to ask djdolphin to add the following script to each project. What do you think @djdolphin?

Won't that require replacing every green flag hat (except the one in that script) with "when I receive [green flag]"? Generally I'd like to stick to converting Scratch blocks to their Snap! equivalents, so that means keeping "when green flag clicked" as "when green flag clicked".

I'm also hesitant to generate entirely new scripts that implement functionality usually provided by the Scratch player. But I'm not entirely opposed to it if there's some way to make it clear to the user where it came from, so they don't accidentally delete it, or come complain to me about weird scripts appearing in their project, or something.

Would this work?

And maybe put WAIT 0 SECS at the beginning of any other green-flag scripts, to make sure this one gets to run first.

never thought of that

Thanks Brian. I'd rather not change every script in the project if not necessary.

In my first successful test it didn't.

If it works (read below) I guess we could create a custom block, so that it is clear to the user why the script is there.

But I tried @ego-lay_atman-bay's script again in a much larger project with many sprites and many scripts. The script worked well in the small sample project but this time, in the large project, it doesn't work. I also tried adding a wait block after the stop block, but it didn't work either.

I don't understand why having many scripts would interfere. Maybe the STOP ALL BUT THIS SCRIPT block yields to other blocks? I guess @jens knows that. If this is the case, I guess it should become a STOP ALL BUT THIS SCRIPT AND WAIT. There is no point in running the next blocks if all the other scripts have no stopped yet, is there? As I understand it, it should already wait. But I can be wrong.