 That yellow category refers to events in Scratch, but just how do you use Scratch events? Well stick around, because in this Scratchery Basics tutorial, I'll explain each Scratch event block through some work examples, including how to broadcast a message to communicate between sprites. Coming up! Hello world, Surfing Scratcher here, bringing you the goodness of learning to code through video tutorials. If that sounds like what you're about, then consider hitting that subscribe button to stay in the loop. Be sure to check out the show notes below, hit the show more button because I've listed out a bunch of resources that can help you along on your learning journey. Alright, let's start learning about events in Scratch. Here we are in the Scratch project, I don't know if you haven't already. Jump over to the events category. It's yellow so we can suss out these blocks. So just what are events in Scratch? Well as you can see, most of them are hat blocks that have these like little rounded tops and we know based on our Scratch Blocks Explained tutorial that a hat block starts a sequence of instructions. You'll be very familiar with the when the green flag is clicked hat block because we know when we click this green flag, we start the project. So we've got a couple of sprites down here, blob and bulb. And what we want to do when the green flag is pressed is we want to show them. So let's do that. Press the green flag and here we are away. I'm going to drag this block and put it over bulb. So when I press the green flag, both will appear now. Yay! Alright, let's check out the next hat event block. And this is when a particular key is pressed. Now if we click this parameter here, we can select virtually any key that's on the keyboard. We can refer to a specific key such as the up arrow and when the up arrow is pressed on the keyboard, we can start a sequence of instructions. So let's go into our look blocks and increase the size of our blob. Cool. Let's duplicate that and let's decrease the size on a down arrow press. Cool. Now when I press the up arrow now, you can see our blob size increases and when I press the down arrow, its size decreases, you'll see the size also change over here in the sprite view. The next event hat block to talk about is when the sprite is clicked. I'm actually going to jump over to the stage and demonstrate this one in the stage. So when the stage is clicked, so what that means is when I click the stage, this will activate this set of instructions. What we'll do is we'll head across into our backdrops and we're just going to get a few surprise backdrops here. So I don't know what it's going to serve up. All a bit of fun. Cool. Looks great. So if we jump over here, so when the stage is clicked, let's just go to the next backdrop. I'm going to click the stage here and look, we're going to the next backdrop. Boom. That's a neat little segue to the next hat block for our events. When the backdrop switches to a particular backdrop. So here are the three backdrops plus the existing one that we just added. So we can respond to when we switch to one of those backdrops. So let's go to the forest. And we can get our blob to say something for a couple of seconds. When I click the stage and we go to the forest. Oh yeah. I love the forest. Doesn't work for any other backdrop. All right. The next hat event block is called when a particular property is greater than a value. So here we can refer to the microphone's loudness or the scratch timer, which by default when you press the green flag starts, it's always counting in the background. So it will play around with this loudness value. And when the loudness gets bigger, let's say 60, this is just a random sort of values between zero and 100. But you just have to play around with your own voice to see when scratch initiates this one. And what we'll do is we will get our blob to again say, so I think scratcher. All right. So if I just start talking to the microphone, our orange blob is telling me to, okay, I'm just going to disconnect that. Otherwise that'll be a little bit annoying for us. Okay. I want to talk about these next three blocks here. So one of them is a hat block and these two are stack blocks. So events and scratch enables you to communicate between sprites as well. So that's what we'll use these three to do for us. I hope you're pretty familiar with a walkie talkie. Walkie talkies allow us to communicate between people. So we're going to use that idea and show it to you with these sprites. So let's give our orange blob a walkie talkie. Now orange blob wants to talk to the pink blob. All right. So let's grab out a when the space key is pressed and then let's grab a new message. And we're going to say, I bet you can't change your color. If I press the space bar, you'll see ever so slightly that a yellow outline appears around our scripts here, but nothing happens. And that's because nothing is currently listening to this event here, this broadcast message. So we need to go ahead and change that. We need to give our bulb sprite a walkie talkie. Just to be clear, it's not the actual graphics that are allowing them to communicate. It's the blocks. So let's go ahead into our bulb sprite and let's receive that message now. When I receive, I bet you can't change your color. Let's go do something now. Let's get our bulb to say, oh, yes, I can for two seconds. Then after that, we'll get it to change its color. If I press the space bar here, oh, yes, I can. And then our bulb will change its color and it looks pretty cool. As you can see, our bulb doesn't have the walkie talkie still, but that's just a graphic. I can go in and change that. If I press the space bar again, you'll see our blob is now listening to that message and can change its color. All right, let's talk about the last event stack block here and that is broadcast the message and wait. So what that means is it does the exact same thing by broadcasting the message. But the extra here, the and wait part means that any sprite or anything that is handling this event, so receiving it here, it will execute all those instructions and then this will continue. Okay, so at the moment, this instruction will fire and then it would go directly to the next instruction if there was one beneath it. I can show you that by just getting another say block here and get a well played. So if I press the space bar, everything happens at once, which isn't really what we want. So what we can do is instead of just firing the event, we can wait until it is finished executing. So if we just attach these blocks now and we press the space bar, I bet you can't change your color. Yes, I can change his color. And then we get the well played. So that what that has done is we press the space bar, it goes over to our bulb. It executes these, see this takes three seconds, when we get to the end, our blob finishes by saying well played. That's events in scratch. All right, it's time for a scratchy question. And I want to know what you think about naming events in scratch. Are you someone who uses pretty descriptive names that describe what the event does in scratch? Or are you somebody who uses something pretty random to name their events? Drop an answer in the comments below. Hey, thanks for checking out this scratch tutorial, like, subscribe, ring that bell if you're new around here and have a scout of some of my other content, which is on the screen right now. If you want to show your support for surfing scratchy, then you can head on over to my Patreon page and join a membership tier, which also gives you access to some exclusive content. But until then, I'm off to go find a way. I'll catch you in the next one.