1 00:00:00,000 --> 00:00:05,440 What if we want to perform the same sequence of code, execute the same procedure each time the 2 00:00:05,440 --> 00:00:10,880 custom block is called in the main program, but each time we want to make small changes, 3 00:00:10,880 --> 00:00:16,559 like the text shown, or the coordinate used, or adjust the value in one or more of these blocks? 4 00:00:17,120 --> 00:00:21,920 Let's learn how to create a MyBlock block that can be customized each time it is used. 5 00:00:22,559 --> 00:00:26,399 Let's start by setting up a custom block that has the character speak and say 6 00:00:26,399 --> 00:00:32,640 certain text at the same time you'll see the code stack i want to use here i'll click the mega block 7 00:00:32,640 --> 00:00:38,159 and give it a descriptive name as before like speak and say but since i want to customize the 8 00:00:38,159 --> 00:00:44,320 text my sprite will speak and say each time i'm also going to add an input with an input in place 9 00:00:44,320 --> 00:00:50,159 the custom block will use the parameter the data i provide in the input bubble when i use the block 10 00:00:50,159 --> 00:00:55,719 block. In this case, the input I'm choosing is number or text, and so I remember what 11 00:00:55,719 --> 00:01:00,960 the input is, I also want to give it a descriptive name, like, what to say. 12 00:01:00,960 --> 00:01:06,439 Back in my scripts area, I'll add the desired code sequence under the define block. Then, 13 00:01:06,439 --> 00:01:11,400 in place of static, unchanging text in the speak and say blocks, I want to use the input 14 00:01:11,400 --> 00:01:13,659 I created while creating my block. 15 00:01:13,659 --> 00:01:18,099 To get the input, click on the input label in the define block, and drag it out to place 16 00:01:18,099 --> 00:01:19,879 it in a code block. 17 00:01:19,879 --> 00:01:24,659 In this case, I want to use the same text in both the speak and say blocks, so I'll 18 00:01:24,659 --> 00:01:25,659 do that two times. 19 00:01:25,659 --> 00:01:30,400 Now, when I use this custom block in my main program, you can see the blank input bubble 20 00:01:30,400 --> 00:01:34,280 where I can enter the parameter, in this case my custom text. 21 00:01:34,280 --> 00:01:36,340 Let's run the code to see how it looks. 22 00:01:36,340 --> 00:01:38,439 Hi, I'm a dragon. 23 00:01:38,439 --> 00:01:39,739 I have hot breath. 24 00:01:39,739 --> 00:01:44,459 I'm able to use the same code sequence and customize it over and over without rewriting 25 00:01:44,459 --> 00:01:46,400 this code stack each time. 26 00:01:46,400 --> 00:01:54,159 If I need to make edits to the procedure, I only need to make changes under the Define block to update everywhere the block is used in my main program. 27 00:01:54,159 --> 00:01:58,000 Hi, I'm a dragon. I have hot breath. 28 00:01:58,000 --> 00:02:03,799 Let's see another example where I want to customize the X and Y coordinate every time I run my custom block. 29 00:02:03,799 --> 00:02:12,180 As I create my custom block, I can add labels between inputs to help me remember what is what as I use the block and fill in the parameters.