Coding with Minecraft: Build Taller, Farm Faster, Mine Deeper, and Automate the Boring Stuff
Chapter 6 Programming a Robot Lumberjack features a program to make a turtle chop down a single tree and collect its wood Chapter 7 Creating Modules to Reuse Your Code teaches you how to write code once and share it with multiple programs Chapter 8 Running an Automated Tree Farm extends the program from Chapter 6 to create a fully automated tree farm so your turtles can harvest wood from multiple trees Chapter 9 Building a Cobblestone Generator features a program for mining unlimited amounts of cobblestone which the turtles will use as building material for Chapters 10 through 13 Chapter 10 Making a Stone Brick Factory features a program to turn the cobblestone from Chapter 9 into stone bricks Chapter 11 Constructing Walls includes a program that uses stone bricks to build walls Chapter 12 Constructing Rooms contains a program that lets you join walls together to build rooms Chapter 13 Constructing Floors features a program to build floors and ceilings for your rooms Chapter 14 Programming a Robotic Farm features a program to make turtles plant and harvest different kinds of crops so you can keep yourself fed Chapter 15 Programming a Staircase Miner features a program that digs stairs deep into the ground to mine ore and other valuable blocks The Function Reference lists and explains how to use all the functions in this book The Name ID Reference lists commonly used Minecraft blocks and items along with their name IDs which you’ll use to identify block types and other items in your programs getting help Minecraft famously lacks a tutorial for new players It doesn’t have an instruc tion manual or even a help menu Minecraft forces you to be responsible for your own education You’ll need to do online research form questions find answers and sometimes just do some plain old experimentation Minecraft cultivates a growth mindset in players Even after falling into lava or having their base blown up by a creeper players come back determined to learn how to overcome these problems However this book is about the ComputerCraft mod not the basics of playing Minecraft To use this book you should already know how to do the following in Minecraft Mine for ore stone coal wood and other blocks Craft a workbench and tools such as axes shovels torches and pickaxes xx introduction
Craft a furnace fuel it and then smelt ore blocks or cook meat in it Craft stairs ladders chests doors fences and other parts you’ll use for buildings Plant seeds and farm food If you don’t know how to do all of these things don’t worry You can teach yourself by searching online Go to the search engine of your choice and enter the word minecraft along with what you want to learn For example you could use the search terms minecraft smelt ore minecraft bake cake or even just minecraft basic tutorial to find the information you need You can also search for Minecraft video tutorials on websites such as https www youtube com by using the same search terms you would use in a search engine As I mentioned previously because ComputerCraft isn’t made by the same people as Minecraft most Minecraft websites won’t have informa tion about CC You can learn about CC from the ComputerCraft Wiki at http www computercraft info wiki If you have questions specific to CC you can sign up for a free account on the ComputerCraft forums at http www computercraft info forums2 If you have additional questions about the programs in this book you can post those to the community at https www reddit com r turtleappstore online resources You can download all the programs in this book directly from inside the Minecraft game see Sharing and Downloading Programs Online on page 42 for instructions And although Minecraft doesn’t support copy ing and pasting text from outside the game all the code and resources for this book are available for reference on its companion website https www nostarch com codingwithminecraft There you can also download the code for the bonus activities if you get stuck and want to check out the solutions You’ll also find links to the installation files see Chapter 1 for detailed installation instructions If you want to explore other programs or share your code you can do so through https turtleappstore com which is a free website for ComputerCraft scripts see turtleappstore com on page 44 for details what You learned Minecraft is a gaming phenomenon that can be played in many ways and appeals to a diverse crowd of players In this book you’ll learn how to build more in less time using ComputerCraft a mod that lets you program turtles in the Lua programming language By learning to program with Lua and CC you can automate many jobs you would otherwise have to do by your self including mining farming building and crafting Using Minecraft and ComputerCraft you’ll solve problems indepen dently and learn basic computer programming skills along the way Let’s begin introduction xxi
1 geTTing STArTeD wiTh CoMPuTerCrAFT Before you can start programming robotic turtles to do your bidding you’ll need to install and set up Minecraft and the ComputerCraft mod Fortunately the free ATLauncher software makes this process painless In this chapter I’ll show you how to obtain Minecraft and the ComputerCraft mod and then I’ll walk you through all the configuration steps you’ll need to do before you start programming installing Minecraft ATlauncher and ComputerCraft Configuring Minecraft’s mods used to be tricky because it involved a series of complicated steps However you can now use the ATLauncher software to load mods into Minecraft more easily Because Minecraft ATLauncher and