33
CoderDojo – Building objects in MineCraft using JavaScript Objective Today we will learn how to create a MineCraft mod. A mod is code you write that allows you to modify MineCraft. A mod can be anything from a new type of block to build with in MineCraft, to a new game that is played in the MineCraft world. For our mod, we will be creating a function that will build objects in our MineCraft world. What are all the pieces we need? MineCraft: We need MineCraft installed on our laptops. We also need to have a MineCraft account in order to play the game. Java: We need to have the latest version of Java installed on your laptop. We use Java to run the MineCraft server. MineCraft Server: We need to run a MineCraft server. The server will be running ScriptCraft. ScriptCraft is an extension for MineCraft that allows us to write JavaScript mods. We already created a MineCraft server (called CanaryMod) that has ScriptCraft installed. All we need to do is copy the server to your laptop and run it. A code editor: A code editor allows us to type in and save our JavaScript mods. We can use any text editor to write JavaScript mods. Page 1

CoderDojoprojects.swisscoderdojo.org/Minecraft/HANDOUT_CoderD…  · Web viewwidth - the width of the prism. length - the length of the prism (will be 2 time its height) Example

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

CoderDojo – Building objects in MineCraft using JavaScript

Objective

Today we will learn how to create a MineCraft mod. A mod is code you write that allows you to modify MineCraft. A mod can be anything from a new type of block to build with in MineCraft, to a new game that is played in the MineCraft world.

For our mod, we will be creating a function that will build objects in our MineCraft world.

What are all the pieces we need?

· MineCraft: We need MineCraft installed on our laptops. We also need to have a MineCraft account in order to play the game.

· Java: We need to have the latest version of Java installed on your laptop. We use Java to run the MineCraft server.

· MineCraft Server: We need to run a MineCraft server. The server will be running ScriptCraft. ScriptCraft is an extension for MineCraft that allows us to write JavaScript mods. We already created a MineCraft server (called CanaryMod) that has ScriptCraft installed. All we need to do is copy the server to your laptop and run it.

· A code editor: A code editor allows us to type in and save our JavaScript mods. We can use any text editor to write JavaScript mods.

Acknowledgement

The MineCraft server plug-in we use is called ScriptCraft. The plug-in and a lot of the Drone documentation in this document was created by a guy called Walter Higgins. You can find out a lot more about Scriptcraft by following the link below.

https://github.com/walterhiggins/ScriptCraft/blob/master/docs/YoungPersonsGuideToProgrammingMinecraft.md

Walter also has a book on the subject, available here: http://www.amazon.co.uk/dp/0133930149

Setup

Getting Started Cheat Sheet

Drawing your first block

For more information, see the next section.

1. Run the Server

a. Start the Terminal

b. Type cd Desktop

c. Type cd Canarymod

d. Type ./start.sh

2. Give yourself op permissions

a. Go to the server console window

b. Type op yourminecraftname and press enter, where yourminecraftname is your MineCraft account name.

3. Start MineCraft and connect to the server

a. Run the MineCraft Launcher

b. Make sure your MineCraft profile is set to run MineCraft version 1.8.9. Ask a to help if you are not sure how to do it.

c. Once MineCraft has been launched Select Multiplayer

d. Select Direct Connect

e. Type localhost in the Server Address

f. Click Join Server

4. Build your first block

a. In MineCraft, type / to bring up the MineCraft Console

b. Continue typing /js box(blocks.iron,5,5,5) and press enter

The MineCraft Console

Figure 1The MineCraft Console

This is the MineCraft Console. You can reach this by pressing / while in MineCraft. You can do the following things in the MineCraft Console:

· Run your mods by typing: /js mymodname()

· Reload your mods after making a change by typing /js refresh()

· Turn off the rain or snow by typing /toggledownfall

· Set the time of day by typing /time set 9000 (for early morning)

You can also run some of these commands (and others) in the server console window. See the next section to learn about the server consoler window.

Mod Ideas

Here are some ideas you can use for your mod, or come up with your own idea!

Simple HouseUse a box, a prism, some glass blocks and a door to make a simple house with a roof. (Use Sushi Card 1)

PyramidUse boxes stacked on top of each other and getting smaller to make a pyramid. Make an entrance and hang some torches inside. (Use Sushi Card 2)

A-MAZE-ingCan you plan a maze on a piece of grid paper? Now can you write some JavaScript to build this maze in MineCraft? Now you can challenge your friends to solve your maze! (Use Sushi Card 3)

SkyscraperBuild a house with a flat roof, and some stairs that run up to the flat roof. (Remember to make a hole in the roof where you want the stairs to come out!) Now use a JavaScript loop to stack 10 of these houses on top of each other, and you have your own skyscraper!

TowerUse the cylinder0 method to make a tower. You can give it a cone roof by adding 1 block thick cylinders with the radios decreasing down to 1. Or use a hemisphere for a domed roof!

Rocket!Can you convert your tower into a rocket? Try adding some fins by using the prism method.

CastleCan you take 4 towers and some walls to make a castle? Remember to make a hole in one of the walls if you want to walk into your castle.

TreeUse a cylinder made from wood and a sphere made from something green and create your own giant tree.

CaterpillarCan you use some spheres and make something that looks like a caterpillar?

RainbowUse arc, and coloured stained glass blocks and make a giant rainbow!

Sushi 1 - Build a House

Planning Your House

B

B

B

B

B

B

B

B

B

B

B

B

B

B

B

B

B

B

W

W

B

D

B

W

W

B

Testing your mod

1. in the Minecraft console, type /js refresh()to reload the mod

2. Point your crosshairs at an empty spot on the ground and type /js house()

Remember: To look at the server console for any errors!

Step 1 – Open your mod file

1. Open the text editor: Sublime Text.

2. In the editor, open the file: Desktop\ CanaryMod\scriptcraft\plugins\coderdojo\house.js

Step 2 – Lay the carpet

1. Move your cursor below the line that says:

2. Move the drone up and add code for the carpet (9 wide, 1 high, 6 deep):

3. Save the file and test your mod:

Step 3 – Build the walls

1. Move your cursor below the last line you added

2. Create a checkpoint!

3. Add code for the brick walls (9 wide, 5 high, 6 deep):

4. Save the file and test your mod:

Step 4 – Put the roof up

1. Move your cursor below the last line you added

2. Move the drone up by 5 blocks and add the roof:

3. Save the file and test your mod:

Step 5 – Add some windows

1. Move your cursor below the last line you added

2. Move back to the checkpoint, move to the place for window 1, and place the window. Repeat for window 2.

3. Save the file and test your mod:

Step 6 – Add a door

1. Move your cursor below the last line you added

2. Move the drone to the checkpoint, go right and place the door

3. Save the file and test your mod:

Other things you can do

Can you change the blocks that the house is made from?

Can you add a back door? Or some extra windows at the back of the house?

Can you make the house bigger?

Sushi 2 - Pyramid

Planning your pyramid

4

2,3

5

1

5

Testing your mod

1. in the Minecraft console, type /js refresh()to reload the mod

2. Point your crosshairs at an empty spot on the ground and type /js pyramid()

Remember: To look at the server console for any errors!

Step 1 – Open your mod file

1. Open the text editor: Sublime Text.

2. In the editor, open the file: Desktop\ CanaryMod\scriptcraft\plugins\coderdojo\pyramid.js

Step 2 – Place the first box

1. Move your cursor below the line that says:

2. Create a variable that says how big the pyramid will be:

3. Move the drone up by one, and create a checkpoint (so we can go back later):

4. Now place the first box:

5. Save the file and test your mod:

Step 3 – Do it again and again and again…

1. Move your cursor below the last line you added

2. Subtract 2 from size:

3. While size is still larger than 0

a. Move the drone up, right and forwards.

b. Place another box

c. Subtract 2 from size

4. Save the file and test your mod

Step 4 - Make a door

1. Move your cursor below the line that says:

2. Move the drone to the checkpoint we made previously:

3. Move the drone right until it is halfway along the pyramid:

4. Now let us make a big hole ine the side of the pyramid:

5. Save the file and test your mod

Other cool things to do

1. Use the following code to hang torches inside your pyaramid:

2. Can you make the pyramid bigger? Change size to 31 and see!

Sushi 3 – A-MAZE-ing

Planning the Maze

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4

4

4

4

4

4

4

5

4

1

1

4

11

4

1

1

4

8

8

8

8

11

4

1

1

4

10

14!

11

4

1

1

4

9

9

9

9

9

11

4

1

1

4

11

4

1

1

4

6

6

12

11

4

3

1

1

4

6

6

12

13

11

4

1

1

4

7

4

1

1

4

4

4

4

4

4

4

4

4

4

1

1

1

1

1

1

1

1

1

2

1

1

1

1

1

1

1

Testing your mod

1. in the Minecraft console, type /js refresh()to reload the mod

2. Point your crosshairs at an empty spot on the ground and type /js mymaze()

Remember: To look at the server console for any errors!

How to do it

1. Open the text editor: Sublime Text.

2. In the editor, open the file: Desktop\ CanaryMod\scriptcraft\plugins\coderdojo\mymaze.js

3. Below is all the code for the maze. You can save and test after every step to make sure you haven’t made any mistakes.

var mazeblock = blocks.brick.red;

d.up();

d.chkpt('begin');

//step 1

d.box0(mazeblock, 28, 4, 28);

d.right().fwd();

d.box0(mazeblock, 26, 4, 26);

// step 2

d.move('begin');

d.right(12);

d.box(blocks.air, 2, 3, 2);

//step 3

d.move('begin');

d.right(24).fwd(10);

d.box(mazeblock, 2, 4, 2);

//step 4

d.move('begin');

d.right(4).fwd(4);

d.box0(mazeblock, 20, 4, 20);

d.fwd().right();

d.box0(mazeblock, 18, 4, 18);

//step 5

d.move('begin');

d.right(20).fwd(22);

d.box(blocks.air, 2, 3, 2);

//step 6

d.move('begin');

d.right(8).fwd(8);

d.box(mazeblock, 4, 4, 4);

//step 7

d.move('begin');

d.right(10).fwd(6);

d.box(mazeblock, 2, 4, 2);

//step 8

d.move('begin');

d.right(8).fwd(18);

d.box(mazeblock, 8, 4, 2);

//step 9

d.move('begin');

d.right(8).fwd(14);

d.box(mazeblock, 10, 4, 2);

//step 10

d.move('begin');

d.right(8).fwd(16);

d.box(mazeblock, 2, 4, 2);

//step 11

d.move('begin');

d.right(18).fwd(8);

d.box(mazeblock, 2, 4, 14);

//step 12

d.move('begin');

d.right(14).fwd(8);

d.box(mazeblock, 2, 4, 4);

//step 13

d.move('begin');

d.right(16).fwd(8);

d.box(mazeblock, 2, 4, 2);

//step 14

d.move('begin');

d.right(10).fwd(17);

d.turn(3).up();

d.hangtorch();

d.left();

d.hangtorch();

MineCraft Server Cheat SheetStarting the MineCraft Server

1. Open the Terminal

2. Type cd Desktop

3. Type cd Canarymod

4. Type ./start.sh

This will open a window. We call this the server console window. In the server console window, you will see the server starting. If there is a problem with the code for your mod, you will also it appear in the server console window.

Figure 2The server console window

Connecting to the server

1. Run the MineCraft Launcher

2. Make sure your MineCraft profile is set to run MineCraft version 1.8.9. Ask a mentor to help if you are not sure how to do it.

3. Once MineCraft has been launched Select Multiplayer

4. Select Direct Connect

5. Type localhost in the Server Address

6. Click Join Server

Give yourself permission to run mods

You need the right permissions in the MineCraft server to do things like run a mod.

1. Go to the server console window

2. Type op yourminecraftname and press enter, where yourminecraftname is your MineCraft account name.

Where should I save my mods?

All MineCraft mods should be saved here:

\scriptcraft\plugins\coderdojo

Where canarymod folder is the folder where we copied the canarymod server. You will find a couple of mods in that folder already. Open one of them and have a look at how a mod is written.

All mods must have an extension of .js, this tells the server that the file contains a ScriptCraft mod.

Reloading your mod after you make a change

After you have made changes to your mod and saved it, you will want to tell the server to reload the mods so you can test it! To do this:

1. Go to the server console window

2. Type /js refresh() and press enter

Creating a new world when the one you are using gets too full

1. Go to the server console window

2. Stop the server by typing stop and press enter

3. Type ./reset.sh

4. Start the canarymod server again by typing ./start.sh

Stop the day/night cycle

You can use the following two commands in the server console window to help control the time of day:

/time set 6000

Sets the time to early morning

/gamerule doDaylightCycle false

Turns off the day/night cycle

Stop the snow/rain

Use the following command in the server console window to stop it raining or snowing

/Toggledownfall

ScriptCraft Mod Cheat Sheet

What does a mod look like?

exports.mymod = function()

{

echo('Running my mod!');

var d = new Drone(self);

//YOUR CODE GOES BELOW

}

The Drone

The Drone is your personal invisible servant in the MineCraft world. Your code will tell the drone where to go, and what MineCraft blocks to put down.

Moving the Drone

Assuming your Drone is called d, you can you use the following code to move the Drone around:

d.up( numberOfBlocks ) moves the Drone Up. For example: up() will move the Drone 1 block up. You can tell it how many blocks to move if you want it to move more than one block.

d.down( numberOfBlocks )moves the Drone Down.

d.left( numberOfBlocks )moves the Drone Left.

d.right( numberOfBlocs )moves the Drone Right.

d.fwd( numberOfBlocs )moves the Drone Forward (away from the player).

d.back( numberOfBlocs )moves the Drone Back (towards the player)

d.turn( numberOfTurns ) Turns the Drone Clock-wise (right). For example: turn() will make the Drone turn right 90 degrees. turn(2) will make the Drone turn twice so that it is facing in the opposite direction.

Checkpoints

If you want your Drone to remember a certain location in the MineCraft world, and want it to return to that location (for example if you want to return to the beginning), you use Checkpoints.

You give a Checkpoint a name, and then you can tell the drone to return to the Checkpoint whenever you want.

d.chkpt( name ) Creates a checkpoint at your Drone's current location so it can return there later. Think of it as giving a name to the place where your Drone is located. Use any name you want, but put them in single quotes, for example: d.chkpt('beginning')

d.move( name )Moves your Drone to a location you named using chkpt() . It brings your Drone back to the place where you saved it. Put the name in single quotes, for example: d.move('beginning')

Basic Objects

It would take forever to build structures one block at a time. Thankfully ScriptCraft has several basic objects that we can build easily. Here are some of the ones we can use today!

1 - Drone.box() method

The box() method is a convenience method for building things.

parameters

· b - the block type - e.g. blocks.sapling.birch (See Block Type section below)

· w (optional - default 1) - the width of the structure

· h (optional - default 1) - the height of the structure

· d (optional - default 1) - the depth of the structure - NB this is not how deep underground the structure lies - this is how far away (depth of field) from the drone the structure will extend.

Example

To create a black structure 4 blocks wide, 9 blocks tall and 1 block long...

d.box(blocks.wool.black, 4, 9, 1);

2 - Drone.box0() method

Another convenience method - this one creates 4 walls with no floor or ceiling.

Parameters

· block - the block type, e.g. blocks.sapling.birch. (See the block type section below.)

· width (optional - default 1) - the width of the structure

· height (optional - default 1) - the height of the structure

· length (optional - default 1) - the length of the structure - how far away (depth of field) from the drone the structure will extend.

Example

To create a stone building with the insided hollowed out 7 wide by 3 tall by 6 long...

d.box0( blocks.stone, 7, 3, 6);

3 - Drone.cylinder() method

A convenience method for building cylinders. Building begins radius blocks to the right and forward.

Parameters

· block type - the block type - e.g. blocks.sapling.birch (See Block Type section below.)

· radius

· height

Example

To create a cylinder of Iron 7 blocks in radius and 1 block high...

d.cylinder(blocks.iron, 7 , 1);

4 - Drone.cylinder0() method

A version of cylinder that hollows out the middle.

Example

To create a hollow cylinder of Iron 7 blocks in radius and 1 block high...

d.cylinder0(blocks.iron, 7, 1);

5 - Drone.door() method

create a door - if a parameter is supplied an Iron door is created otherwise a wooden door is created.

Parameters

· doorType (optional - default wood) - If a parameter is provided then the door is Iron.

Example

To create a wooden door at the drone's location...

d.door();

To create an iron door...

d.door( blocks.door_iron );

6 - Drone.prism() method

Creates a prism. This is useful for roofs on houses.

Parameters

· block - the block type - e.g. blocks.sapling.birch (See Block Type section below.)

· width - the width of the prism

· length - the length of the prism (will be 2 time its height)

Example

d.prism(blocks.oak,3,12);

7 - Drone.prism0() method

A variation on prism which hollows out the inside of the prism. It uses the same parameters as prism.

8 - Drone.sphere() method

Creates a sphere.

Parameters

· block - The block type the sphere will be made of. (See the section on Block Type below.)

· radius - The radius of the sphere.

Example

To create a sphere of Iron with a radius of 10 blocks...

d.sphere( blocks.iron, 10);

9 - Drone.sphere0() method

Creates an empty sphere.

Parameters

· block - The block the sphere will be made of. (See the section on Block Type below.)

· radius - The radius of the sphere.

Example

To create a sphere of Iron with a radius of 10 blocks...

d.sphere0( blocks.iron, 10);

10 - Drone.hemisphere() method

Creates a hemisphere. Hemispheres can be either north or south.

Parameters

· block - the block the hemisphere will be made of. (See the section on Block Type below.)

· radius - the radius of the hemisphere

· northSouth - whether the hemisphere is 'north' or 'south'

Example

To create a wood 'north' hemisphere with a radius of 7 blocks...

d.hemisphere(blocks.oak, 7, 'north');

11 - Drone.hemisphere0() method

Creates a hollow hemisphere. Hemispheres can be either north or south.

Parameters

· block - the block the hemisphere will be made of. (See the section on Block Type below.)

· radius - the radius of the hemisphere

· northSouth - whether the hemisphere is 'north' or 'south'

Example

To create a glass 'north' hemisphere with a radius of 20 blocks...

d.hemisphere0(blocks.glass, 20, 'north');

12 - Drone.arc() method

The arc() method can be used to create 1 or more 90 degree arcs in the horizontal or vertical planes. This method is called by cylinder() and cylinder0() and the sphere() and sphere0() methods.

Parameters

arc() takes a single parameter - an object with the following named properties...

· radius - The radius of the arc.

· blockType - The type of block to use - this is the only (no meta, the bit before the : ). (See Block Type section below.)

· meta - The metadata value (the bit after the : ). (See Block Type section below.)

· orientation (default: 'horizontal' ) - the orientation of the arc - can be 'vertical' or 'horizontal'.

· stack (default: 1 ) - the height or length of the arc (depending on the orientation - if orientation is horizontal then this parameter refers to the height, if vertical then it refers to the length ).

· strokeWidth (default: 1 ) - the width of the stroke (how many blocks) - if drawing nested arcs it's usually a good idea to set strokeWidth to at least 2 so that there are no gaps between each arc.

· fill - If true (or present) then the arc will be filled in.

· quadrants (default: {topleft:true,topright:true,bottomleft:true,bottomright:true} - An object with 4 properties indicating which of the 4 quadrants of a circle to draw. If the quadrants property is absent then all 4 quadrants are drawn.

Examples

To draw a 1/4 circle (top right quadrant only) with a radius of 10 and stroke width of 2 blocks ...

d.arc({blockType: blocks.iron,

meta: 0,

radius: 10,

strokeWidth: 2,

quadrants: { topright: true },

orientation: 'vertical',

stack: 1,

fill: false

} );

13 - Drone.stairs() function

The stairs() function will build a flight of stairs

Parameters

· blockType - should be one of the following:

· blocks.stairs.oak

· blocks.stairs.cobblestone

· blocks.stairs.brick

· blocks.stairs.stone

· blocks.stairs.nether

· blocks.stairs.sandstone

· blocks.stairs.spruce

· blocks.stairs.birch

· blocks.stairs.jungle

· blocks.stairs.quartz

· width - The width of the staircase - default is 1

· height - The height of the staircase - default is 1

Example

To build an oak staircase 3 blocks wide and 5 blocks tall:

d.stairs(blocks.stairs.oak, 3, 5)

Block Types

Here are some of the block types you can use. Where it ends in COLOUR you can use: white, orange, magenta, lightblue, yellow, lime, pink, gray, lightgray, cyan, purple, blue, brown, green, red, black

blocks.air

blocks.stone

blocks.grass

blocks.dirt

blocks.cobblestone

blocks.oak

blocks.spruce

blocks.birch

blocks.jungle

blocks.sapling.oak

blocks.sapling.spruce

blocks.sapling.birch

blocks.sapling.jungle

blocks.bedrock

blocks.water

blocks.water_still

blocks.lava

blocks.lava_still

blocks.sand

blocks.gravel

blocks.gold_ore

blocks.iron_ore

blocks.coal_ore

blocks.wood

blocks.leaves

blocks.sponge

blocks.glass

blocks.lapis_lazuli_ore

blocks.lapis_lazuli_block

blocks.dispenser

blocks.sandstone

blocks.note

blocks.bed

blocks.powered_rail

blocks.detector_rail

blocks.sticky_piston

blocks.cobweb

blocks.grass_tall

blocks.dead_bush

blocks.piston

blocks.piston_extn

blocks.piston_head

blocks.wool.COLOUR

blocks.piston_extended

blocks.dandelion

blocks.rose

blocks.mushroom_brown

blocks.mushroom_red

blocks.gold

blocks.iron

blocks.double_slab.stone

blocks.double_slab.sandstone

blocks.double_slab. Wooden

blocks.double_slab.cobblestone

blocks.double_slab.brick

blocks.double_slab.stonebrick

blocks.double_slab.netherbrickblocks.double_slab.quartz

blocks.double_slab.smooth_stoneblocks.double_slab.smooth_sandstone

blocks.double_slab.tile_quartzblocks.slab.sandstone

blocks.slab.wooden

blocks.slab.cobblestone

blocks.slab.brick

blocks.slab.stonebrick

blocks.slab.netherbrick

blocks.slab.quartz

blocks.snow

blocks.tnt

blocks.moss_stone

blocks.obsidian

blocks.torch

blocks.fire

blocks.chest

blocks.diamond_ore

blocks.diamond

blocks.ladder

blocks.rail

blocks.sign

blocks.door_iron

blocks.ice

blocks.snow

blocks.cactus

blocks.jukebox

blocks.fence

blocks.glowstone

blocks.stained_glass.COLOUR

blocks.trapdoor

blocks.brick.stone

blocks.brick.mossy

blocks.brick.cracked

blocks.brick.chiseled

blocks.brick.red

blocks.iron_bars

blocks.glass_pane

blocks.fence_gate

blocks.mycelium

blocks.lily_pad

blocks.nether

blocks.nether_fence

blocks.netherwart

blocks.emerald

blocks.redstone

blocks.stained_clay.COLOUR

blocks.stained_glass_pane.COLOUR

blocks.trapdoor_iron

blocks.prismarine

blocks.hay

blocks.carpet.COLOUR

blocks.hardened_clay

blocks.coal_block

blocks.packed_ice

blocks.gate.spruce

blocks.gate.birch

blocks.gate.jungle

blocks.gate.oak

blocks.gate.acacia

blocks.fence.spruce

blocks.fence.birch

blocks.fence.jungle

blocks.fence.oak

blocks.fence.acacia

This tells the server we are creating a new mod called mymod. Feel free to change the name mymod to anything you want! It must be one word without spaces though.

This curly brace marks the beginning of the mod

This curly brace marks the end of the mod

This creates a new Drone. “self” means that the Drone is created beside your MineCraft character. The drone is called d.

This writes a message to the console window

The code for your Drone goes below this line. The // means that this iine is a comment and will be ignored by MineCraft.

This is where the drone will start creating the maze. We should put a checkpoint here so we can return here for each step. To make it easier to walk through the maze we will make all the walls and all the paths 2 blocks wide.

Our Maze Recipe

Draw 28x28 hollow box for the outside wall

Make a gap in the wall

Block the path on the right

Draw a 20x20 hollow box for the 1st inside wall

Make a hole in this wall

Place the 4x4 box

Block the path

Place a 8x2 wall

Place a 10x2 wall

Block the path

Place a 2x14 wall

Place a 2x4 wall

Block the path

Let us hang some torches here to let the player know they reached the end!

d.move('begin');

d.right(4);

d.fwd(4);

d.up(3);

d.turn(2);

var t = 0;

while (t < 4)

{

d.hangtorch();

d.left(3);

d.hangtorch();

d.left(3);

d.turn(3);

t = t + 1;

}

d.box(blocks.air,1,2,3);

d.right(7);

d.move('begin');

while (size > 0) {

d.up().right().fwd();

d.box0(blocks.sandstone,size,1,size);

size = size – 2;

}

d.right().up();

size = size – 2;

d.box0(blocks.sandstone,size,1,size);

d.up();

d. chkpt('begin');

var size=15;

// Start below this line!!

This is where the drone will start creating the maze. We should put a checkpoint here so we can return here later to make the door.

Our Pyramid Recipe

Make a hollow box that is 15 blocks wide, 15 blocks long and 1 block high.

Move the drone up, forwards and right by 1 step.

Now make a box that is 2 blocks shorter and narrower than the last box you made.

Go back to step 2 and keep on making boxes until they become too small (smaller than 1)

Remember to make a hole to walk in!

d.move('begin');

d.right(4);

d.door();

d.move('begin');

d.right().up();

d.box(blocks.glass_pane, 2, 3, 1);

d.right(5);

d.box(blocks.glass_pane, 2, 3, 1);

d.up(5);

d.prism(blocks.wood,9,6);

d.box0(blocks.brick.red, 9, 5, 6);

d.chkpt('begin');

d.up();

d.box(blocks.carpet.red, 9, 1, 6);

// Start below this line!!

This is our starting block.

The windows will be 2 blocks wide and 3 blocks high, and start one block from the ground. First window is 1 block to the right of the starting block, and the second window is 5 blocks to the right of the first window.

The door will be in the middle of the house, i.e. 4 steps to the right of the starting block.

Top View of House

We will build a Brick wall for the house. The wall will be 9 blocks wide, 6 blocks deep and 5 blocks high. We should remember to put a carpet on the ground first, and to use a prism to put a roof on the house!

Page 15