 Hello world, it's The Surfing Scratcher here bringing you another video connecting the world of Scratch to maths. If you haven't already, check the description below for links to previous videos as this one is part of a series. In this video, we're going to be connecting the expand notation at the bottom of our screen to the score on the top left hand corner, right there. So let's get stuck into it. Okay, so here we are back in our space value scratch project for the level five sixes. As you can see, I've gone ahead and I've hooked up the hundreds and the thousands as well. But before we get stuck into it, I just want to bring your attention to a couple of bugs that I've encountered with the scratch platform. And it's through with adding decimal numbers together. I'll show you what I mean by that. So if I go through and I click my thousands here, you'll see my thousands update as they should. Now we know that if my thousands are greater than nine thousandths, then I want to regroup and add a hundredth. But have a look at what happens when we get past eight thousandths or even nine thousandths. Here we are in eight thousandths. I'm going to press this one more time. Now you would expect this to go to nine thousandths. Here we go. It goes back to zero and we regroup. So there's a bug in here and it shouldn't that that's not what we we would expect to be happening. So what I'm going to do here is I'm actually just going to change this to ninety one ten thousandths. Now, so if I put a one there. Now it says when my thousands are greater than nine thousandths and one ten thousandths, so ninety one ten thousandths. Let's go again and click this one thousandth two thousandths three four five six seven eight and nine. So it actually works now. What value is it like you would expect it to be nine thousandths. If we go over here to our thousands variable and we click on it, it will tell us what the actual value of this variable is. I'm going to click it and look, it is nine thousands, but it's got this really obscene small number like really, really, really tiny number that's added to it out of nowhere. I don't know where that's come from, but it just appears to be a bit of a bug in the scratch platform. So just something to look out for while we're doing this. So to get this, if you've accounted that same bug, all you need to do is just add a ten thousandth in there, which is kind of good practice for our decimals. Anyway, OK, so let's get actually into what we are planning to do in this lesson. And that is to finally hook up our score here, our expanded notation after the score in the left hand corner. And before we actually get into the code, let's jump over into the plan. OK, so over here in my scratch planner now and you see what the stage, the variables and the sprites. We're actually going to be working in the stage sprite because that's where we've got some code already set up to handle the calls to update the score. So what is it that we need to be doing? Well, we know we've got our expanded notation here. And what we're going for is we need to smush all this together so we can represent our score value at the top. So what we're going for is something that looks like this, so 5.159. That's what I would expect my score to be if it was up here with these current values. So the way that we would do that is quite simply all we need to do is add our units to our tents to our hundreds to our thousands. Pretty basic addition there. That's all we need to do to take our expanded notation and create a decimal representation. So we want to set our score, set the score to basically that. I'm not going to go and write and bore you with all that because it's all right here. We want to set our score to our units plus tents plus hundreds plus thousands. It's exactly what we need to do. So now that I've got my plan in place, let's go ahead and actually implement it. Cool. So I mentioned that we're going to be doing this in the stage area. And the reason for that is I've gone ahead in the project starter and set up a forever loop here with a custom block called update score. And conveniently, that's what we're going to be using. So if you refer back to our code, we need to set the score. So I know if I'm in the variables here, we know score is a variable to get a set block. So let's go get a set block set the score. That's the one that we're interested in right now. So if I click that, it's not going to do anything because we're setting it straight to zero. If I set my score to one and I click that, look, beautiful. My score is set to one, but that's no good because it'll always be one. So let's go through and make this actually functioning. We know that we need to add these together. So to do that, we're going to need an operator block. So I'm going to get an addition operator here. I'm going to jump back to my variables. So we could just go from left to right. You can actually add these in any order that you wanted to because it's addition. Not the case for all of them though. If we were doing subtraction, it would be a little bit different. So let's get our units and our tents. Okay, beautiful. Units plus tents. Okay, there's not enough space here to enter in our other two variables. So what we'll need to do is actually go ahead and grab another operator. And we can put this block. I like to put them sort of in the second one. But yeah, just to mimic what we've got going on here, I'll make it match so you can see that nice and clear. Great, so I've got my units, got my tents. We're going to add our hundreds. So I could go ahead and put my hundreds in there. But I know then I won't have a spot for my thousands. So I'm actually just going to go ahead and grab another one of these blocks here. And now I've got two spots ready for my hundreds and my thousands. So actually go in there. So let's go get them. Get my hundreds and then I'm going to get my thousands. And that's all in there. The last thing I need to do is I need to put this block inside the set score. All right. With any luck, if I press this, our score should update to 5.189. Here we go. Boom, 5.189. That's exactly what we would expect it to do. Okay. So the last thing that you probably want to account for is the condition of when we've got more than 10 units. So if we go back over to our units and we say we pop, we know that we when we get to greater than nine units, we broadcast and event 10 popped and we say our units back to zero. So we don't actually add a 10 in there. So you might want to go ahead and create another one of these blocks to handle the case for our 10s. We don't actually display our 10s, but you could go ahead and create a block to handle it. And then when you would go back into your stage, you would actually just grab out another operator and find the 10s variable. If you had one, we don't have one in here. We could just go ahead and make that. Okay. We could go and grab our 10s variable and we would just grab another operator block and we could get our 10s in the front and then just add all that in. Now 10s are set to zero, so that won't actually do anything. You'd need to go back over here, duplicate one of these blocks and change, just like you did for the hundreds and the thousands. You need to make one to handle the 10s. Okay. And then that would handle the case for when our units get greater than 10s. Here we go. When nine, I'll click it one more time and we go back to zero. So we'd expect that to go to zero, but we'd also expect a 10 to be added in at the top here. That's probably all I'm going to do in this project. I'll leave it to you to hook up the 10s. That's all for this video. And that one actually completes our series on space value for our level five sixes. Although I will link to an extension video in the description below. It shows you how to add extra place values as well as getting our objects to sort of zoom around the screen to make it slightly more challenging. If you liked this video, give it a thumbs up. And if you want to stay connected to when I release more content, then hit that subscribe button. But until then, I'm off to go find a way. Take it easy.