Every drone method needs to return to where it started, so that when people use it, they can keep track of where the drone is.
To do this, we create a checkpoint at the beginning, and have the drone move back to it at the end.
return() shows that the function is over. It will also print that location if we call this function in the console.
Save, deploy, reload, and call
/js bookshelf(4, 4) to test. Nothing should have changed about the bookshelf, but you should still be able to call it even though it isn't an
Just like with the bookshelf, we are going to convert the function so that we can extend the drone to include it. Here are the steps:
thiskeyword any place you were using your drone (
Drone.extend()with the name of your function as the input.
export.to just a regular named function
Upside-down stairs are tricky. We use the drone
stairs method to make sure that stairs are facing us, but it doesn't have a way to do the up-side-down ones.
This complicated line:
blocks.stars.oak + ":" + (Drone.PLAYER_STAIRS_FACING[d.dir] +4).toString()
Actually just gives us the block ID's
53:8, depending on which way the drone is facing.
Using the same method we used to add a
color parameter to the chandelier, add a parameter called
wood to the
Hint: It will be easiest if you make a variable for the slab material and the stair material
Note: In 1.12, "acacia" and "dark_oak" do not work. You can always test if a material will work by finding a test space and calling
/js box(blocks.stairs.acacia) in game.
This code should work for any slab/stair block. See if you can make a desk out of nether rack!
Next, we are going to use the drone's
.wallsign method to put a sign on the front of the desk.
Just like with custom item lore,
walsign takes an array of strings in quotes as the input. So,
wallsign(["Hello", "", "World"]) would look like:
--------------------------------- | Hello | | | | World | | | ---------------------------------
Congratulations, you have finished building the actual library! In the next lesson, we will add a spooky basement, and a secret passage you can open with a hidden lever to get there.