This lesson assumes that you have completed part 1 and have all the code ready and loaded. If you haven’t then you should go back and import the code as the instructions will not be repeated here.
In this lesson we will use the same functions we imported during part 1, however, we will now look at how we can use different materials to build more interesting structures.
Step 1 – Create a new chat command called make1
Copy the 3 red blocks from the picture below.
Step 2 – Press Start and open your agents inventory
As demonstrated by the picture below you should put 2 different types of blocks in slots 1 and 2 of your agents’ inventory.
Step 3 – Return to code builder and add function call
We will build a rectangle outline that is 6 x 9 blocks so use the rectangleOutline function as demonstrated below.
If you’ve forgotten how to find the function call blocks then click the arrow below and follow the pictured steps:
Adding a function call
Step 4 – Test your new make1 command
When you run your command it should build a rectangle using the blocks in slot 1 and return to the starting position. Next we will fill in the rectangle with a different block type, but first we need to move the agent to the right position.
Step 5 – Move the agent and call another function
After we build the first rectangle we need to move the agent right and forward 1 block. Then we switch the agent to use slot 2 of it’s inventory and call the function to build a filled rectangle. The inside rectangle should be 2 blocks smaller in width and length as it must fit inside the first rectangle. See the code below for details.
Step 6 – Test your code again to see if your agent builds correctly
Your structure should look something like the picture below. There should be 2 different block types and the 2nd rectangle should fit neatly within the first one.
Step 7 – Time to get creative
You can build amazing structures with just these 2 functions and different block types. Your agent can hold up to 27 stacks of blocks. There are also code blocks to move inventory between slots and test how much you have left.
Step 8 – Import my code and experiment
It took quite a few attempts to get this right, but if you import my code with this link like you did in part 1. Remember you have to right-click and select ‘Copy Link Address’. This will give you my ‘make’ command (plus some new functions) that builds a house with a door and front step. You have to give the agent 5 different materials in slots 1-5, but I’m sure you can figure out which ones they are from this picture:
Of course, you could use totally different materials, change the dimensions and come up with something very different. Post pictures of your creations on the social stream on our class page.