1 00:00:00,000 --> 00:00:00,400 2 00:00:00,400 --> 00:00:02,260 >> SPEAKER 1: Let's refine my implementation of cough 3 00:00:02,260 --> 00:00:03,230 a little bit more. 4 00:00:03,230 --> 00:00:06,580 So that rather than just cough a single time, when using a cough block 5 00:00:06,580 --> 00:00:09,780 you can actually specify how many times that sprite should cough. 6 00:00:09,780 --> 00:00:12,000 So this time I'm going to click, make a block. 7 00:00:12,000 --> 00:00:13,615 I'm again going to call it cough. 8 00:00:13,615 --> 00:00:16,200 But this time I'm going to expand these options. 9 00:00:16,200 --> 00:00:20,450 >> There, I can specify that this cough block should take a number as input. 10 00:00:20,450 --> 00:00:22,220 By clicking this icon here. 11 00:00:22,220 --> 00:00:25,850 By default to that input otherwise known as an argument, has a default 12 00:00:25,850 --> 00:00:27,170 name of number 1. 13 00:00:27,170 --> 00:00:30,870 But I'm going to simplify that to just n, as is our commonly named variable 14 00:00:30,870 --> 00:00:32,009 for counting something. 15 00:00:32,009 --> 00:00:33,960 Which in this is coughs. 16 00:00:33,960 --> 00:00:35,780 >> Now, I'm going to go ahead and click OK. 17 00:00:35,780 --> 00:00:38,830 And I have the beginnings again, of a defined puzzle piece. 18 00:00:38,830 --> 00:00:41,120 Otherwise known as a function. 19 00:00:41,120 --> 00:00:45,760 Now, this function is going to allow me to specify in code how many times 20 00:00:45,760 --> 00:00:47,230 Scratch should cough. 21 00:00:47,230 --> 00:00:50,020 So let's grab first that repeats block. 22 00:00:50,020 --> 00:00:53,070 But rather than hard coat a number like 10 or three, as 23 00:00:53,070 --> 00:00:54,290 we've done in the past. 24 00:00:54,290 --> 00:00:58,520 >> Let's grab this variable n and specify that we should repeat a variable 25 00:00:58,520 --> 00:00:59,630 number of times. 26 00:00:59,630 --> 00:01:02,480 N, however many times the user has specified. 27 00:01:02,480 --> 00:01:05,099 Now what do we want Scratch to repeat some number of times? 28 00:01:05,099 --> 00:01:08,520 Well, I want Scratch to say cough for one second. 29 00:01:08,520 --> 00:01:11,810 30 00:01:11,810 --> 00:01:13,600 Then I'd like to give him a moment's break. 31 00:01:13,600 --> 00:01:16,710 32 00:01:16,710 --> 00:01:21,030 >> And now I need to actually call that function in my actual program by 33 00:01:21,030 --> 00:01:22,550 telling Scratch to cough. 34 00:01:22,550 --> 00:01:26,680 So I'm going to drag my newly made cough puzzle piece. 35 00:01:26,680 --> 00:01:30,460 And now rather than use the default of 1, I'm going to go ahead and specify 36 00:01:30,460 --> 00:01:31,560 three coughs. 37 00:01:31,560 --> 00:01:35,080 So now what's about to happen when I click the green flag is my cough 38 00:01:35,080 --> 00:01:37,010 puzzle piece is going to get executed. 39 00:01:37,010 --> 00:01:41,660 >> That number 3 is going to be past in to the cough function so to speak. 40 00:01:41,660 --> 00:01:45,620 And that's where the functions code is going to take things from there. 41 00:01:45,620 --> 00:01:49,840 Repeating n times or three in this case, saying cough for a second, 42 00:01:49,840 --> 00:01:54,000 waiting for a second, repeating, repeating, and that's it. 43 00:01:54,000 --> 00:01:56,330 Let's click the green flag. 44 00:01:56,330 --> 00:02:02,030 Cough, cough, cough, and there you it. 45 00:02:02,030 --> 00:02:04,040