## What Will I Learn?

Learn to use repeat loop to build a square.

Use the companion app MakeCode to create a square using blocks of your choice.

### Guiding Ideas

In Minecraft: Education Edition, the Agent is your own personal Robot! You can create programs to make him move, build or dig for you in the game.

In this lesson, we will create basic commands we can use for our Agent.

To do this, we will use a special event in Microsoft MakeCode called the “On Chat Command” which is a useful way to teach students about functions.

In computer science, a “function” is a way to group commands together. For example, the function of Waving might group the following commands together:

• Raise hand
• Move hand left
• Move hand rightIn this case, we will be creating some On Chat Commands that will tell our Agent what to do. Students can type the name of their functions into the Minecraft game to execute that function.

### Performance expectations

• Ask students to change the shape of the structure. What changes to the existing code would they have to make to create a rectangle for example?

### Student Activities

• From the Player Toolbox drawer, drag and drop the On Chat Command block onto the coding Workspace.

The first command we will create is to teleport our Agent to our Player. Rename this On Chat Command to “come”   From the Agent Toolbox drawer, drag and drop the Agent Teleport to Player block onto the coding Workspace.

Drag the Agent Teleport to Player block under the On Chat Command event In your Minecraft game, press ‘t’ to open the chat screen. Type “come” and press Enter. Step back, you should see your Agent right next to you!

Now, let’s add some commands to make your Agent move around. From the Player Toolbox drawer, drag and drop 4 of the On Chat Command blocks onto the coding Workspace.

Rename the 4 On Chat Command blocks to: “forward”, “back”, “left”, and “right”

From the Agent Toolbox drawer, drag and drop 2 of the Agent Move blocks onto the coding Workspace

Drag 1 of the Agent Move blocks under the On Chat Command “Forward” block, and drag the other one under the On Chat Command “Back” block.

Under the On Chat Command “Forward” block, change the number of blocks the agent will move forward by to 5 in the Agent Move block.

Under the On Chat Command “Back” block, using the drop-down menu change the direction the agent will move to back in the Agent Move block.

Under the On Chat Command “Back” block, change the number of blocks the agent will move backwards by to 5 in the Agent Move block.

From the Agent Toolbox drawer, drag and drop 2 of the Agent Turn blocks onto the coding Workspace

Drag 1 of the Agent Turn blocks under the On Chat Command “Left” block, and drag the other one under the On Chat Command “Right” block.
In your Minecraft game, press ‘t’ to open the chat screen. Type “forward” and press Enter. Your Agent should move forward 5 blocks. Try using your other Agent commands “back”, “left”, and “right” to move your agent around in Minecraft.

### Age level

• 8 – 10 years old

### Skills

• Creativity
• Critical thinking

### Requirements

• Windows PC, Mac, Chromebook, or iPad