The Drone

Planning
Step 1
The Drone can be used to build things in Minecraft using JavaScript code!

You can build anything from a simple stone box...

The command: /js box0(blocks.stone, 10, 10, 10)

Temp1476230191



...to a fully functional house!

Planning
Step 2
We'll start by learning to use /js commands to change block types

Once we know how to change a box we can use a Drone to build structures for us.

Step 3
You can change a single block using the box() function

Place a block above ground to use as your starting point and type the command:

/js box(blocks.stone)

Temp1476387962



The result:

Temp1476387936
Challenge
Step 4
Change a block in the ground into a diamond block with the box() function

HINT: blocks.diamond refers to a diamond block.

Temp1476401769
Step 5
We can use export functions to create boxes for us as well

Create an export function named "makeBlock"

Temp1498789979
Step 6
This function now can use box() just like we were doing
Temp1498790078
Check Your Work
Step 7
Deploy and test your export function

Call your makeBlock() function and make sure it does what you expect.

Temp1498790748



The result:

Temp1498790836
Planning
Step 8
Instead of manually targeting each block one at a time, we can have a "Drone" place blocks for us

We'll learn how to do this in the next few steps, for now just check out the animation:

The orange box represents the Drone which can place blocks

Webp.net gifmaker %281%29

Here is what the above program looks like in game:

Planning
Step 9
So how do we make a Drone?

Drones are created inside of export functions.

So let's create a temporary export function:

Temp1498795965
Planning
Step 10
The drone module is unique to scriptcraft; reading the Scriptcraft reference we can learn to use it

This page describes a few ways to create a drone.

This is the approach we will be using:

Temp1498796123
Step 11
Create a new Drone with the name "myDrone"
Temp1498796387

Now if we want to command our Drone we can refer to it with myDrone.

Step 12
We can have the drone place a block at its location by calling .box() on the drone
Temp1498797783

Here we tell myDrone to draw a stone block at its location

Check Your Work
Step 13
If you call the droneTest export function you'll see the drone starts at the targeted block
Temp1506469961
Information
Step 14
Moving the Drone

The Drone can move freely in all 6 possible directions using the following functions:

  • left()
  • right()
  • fwd()
  • back()
  • up()
  • down()
Temp1498795293
Step 15
OPTIONAL: Call .up() when the drone is created so that new blocks are made on top of the target block

This is mostly preference but I like it this way a bit better

Temp1498798192 Temp1498798293
Information
Step 16
Here is the code I used to produce the shape I showed you before

You are not making this!

See if you can verify this code, read it line by line and compare each step to the picture

Temp1498798970
Information
Step 17
You can of course make any block type

Instead of blocks.stone you can try:
blocks.grass
blocks.cobblestone
blocks.gold
etc...

Temp1498799137
Challenge
Step 18
Add to your export function to create this pattern

You should be able to draw this entire structure with one /js command

Temp1476394034
Information
Step 19
We can move more than one space at a time

Calling right() will move the drone one block to the right
Passing a 2 as input like this right(2) will move the block two spaces to the right!

These two drone scripts do the same thing:

Temp1498812677

This of course applies to the other directions as well.

Keep this in mind- it will make your life that much easier!

Challenge
Step 20
Create this pattern using an export function

The drone can begin anywhere you'd like as long as the end result is stone blocks in this configuration!

Temp1476399146
Information
Step 21
Remember, we can also go up and down!

You don't need to write this, just notice:

  1. We can use .up() to go up.
  2. We can save time by writing .up(2) instead of .up() twice
Temp1498813658
Challenge
Step 22
Practice moving the drone by building this structure with your export function from the previous challenge

Alter the code in your draw() function so you can build this with one /js command

Temp1476401210
Planning
Step 23
We're going to practice placing more than one block at a time

As you've seen, if we type /js box(blocks.stone) we get a single stone block.

But we can put an optional three size parameters in this function if we want, which changes the size:

Webp.net gifmaker %282%29

See it in Minecraft:

Step 24
Try it yourself

Place a block above ground to use as your starting position

Target the block and type in the command: /js box(blocks.stone, 2, 3, 4)

Temp1476314540



The result:

Temp1498846062
Challenge
Step 25
Use a single export function to build this quartz tower

HINT: /js box(block, x, y, z);

Temp1476315741
Information
Step 26
Orientations

When you type sizes into the box command the order goes (X, Y, Z)

Temp1498851516

Remember that Z is Forwards and Backwards. Therefore X is Right to Left.

Challenge
Step 27
Use a single export function to build this diamond structure

HINT: /js box(block, x, y, z);

Temp1498852068
Planning
Step 28
Next let's use the drone to build something useful: a working beacon!
Temp1476485319
Planning
Step 29
A beacon is a pyramid of diamond with a beacon block on top

The bottom level is 9 blocks wide and 9 blocks deep.
Each level up is 2 blocks shorter

Temp1498852538
Step 30
Begin by defining a new function createBeacon()

This function will construct a beacon using the drone!

This first call to the box() function will build the first layer of the beacon.

Temp1498854575
Check Your Work
Step 31
Test the first layer of your beacon

Type /js beacon() in game while targeting a block above ground.

Temp1476485601
Step 32
Add the second layer

Before we create the second layer of diamond blocks we need to move the drone to the right location.

Webp.net gifmaker %284%29

How can you move the drone from the:

bottom left corner of the first row

to the:

bottom left corner of the next row?

Temp1476485881
Challenge
Step 33
Add the next two layers of the beacon

HINT: Move the drone to the next starting position, build the next layer, move the drone again, build the final layer

Temp1476486729
Challenge
Step 34
Add the beacon block to the beacon!

HINT: blocks.beacon

Temp1476486825
Check Your Work
Step 35
Make sure you've constructed your beacon properly by selecting a power!
Temp1476486920
Check Your Work
Step 36
Use your beacon() function to give yourself some powers!
Planning
Step 37
Now that you know how to work with the drone, you can use it to build anything for you

For example,if you create a function that builds a nether portal you can call it anytime and head to the nether!

HINT: blocks.fire inside the portal frame will ignite it!

Planning
Step 38
In the next lesson we're going to use the box command to make a spell that turns anything you touch with it into gold
The Drone Info

Account

MVCode Clubs

Created By

Mvcc logo new aaron

Course:

Wand World

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach