Book description
You’ve mined for diamonds, crafted dozens of tools, and built all sorts of structures—but what if you could program robots to do all of that for you in a fraction of the time?
In Coding with Minecraft®, you’ll create a virtual robot army with Lua, a programming language used by professional game developers. Step-by-step coding projects will show you how to write programs that automatically dig mines, collect materials, craft items, and build anything that you can imagine. Along the way, you’ll explore key computer science concepts like data types, functions, variables, and more.
Learn how to:
• Program robots that make smart decisions with flow control• Reuse code so that your robots can farm any crop you want, including wheat, sugar cane, and even cacti!• Program a factory that generates infinite building supplies• Design an algorithm for creating walls and buildings of any size• Code yourself a pickaxe-swinging robotic lumberjack!• Create a robot that digs mine shafts with stairs so you can explore safely
Bonus activities in each chapter will help you take your coding skills to the next level. By the end of the book, you’ll understand how powerful coding can be and have plenty of robots at your beck and call.
Requires: Windows 7 or later; macOS 10.10 or later.
Table of contents
- Cover Page
- Title Page
- Copyright Page
- Dedication Page
- About the Author
- About the Technical Reviewer
- Brief Contents
- Contents in Detail
- Acknowledgments
- Introduction
- 1. Getting Started with ComputerCraft
- 2. Programming Basics
- 3. Talking to Your Turtle
- 4. Programming Turtles to Dance
-
5. Making a Better Dancer
- Writing a Better Dance Program
- Running the mydance2 Program
- The Boolean Data Type
- The nil Data Type
- Looping with while Loops
- Making Decisions with if Statements
- Comparing Two Values with Comparison Operators
- Making Alternate Decisions with elseif Statements
- Nested Code Blocks
- Making a Decision . . . or Else!
- What You Learned
-
6. Programming a Robot Lumberjack
- Equipping Turtles with Tools
- Designing a Tree-Chopping Algorithm
- Writing the choptree Program
- Running the choptree Program
- Detecting Blocks with the Turtle Detection Functions
- Terminating Programs with the error() Function
- Mining Blocks with the Turtle Digging Functions
- Comparing Blocks with the Turtle Comparison Functions
- Returning to the Ground
- Startup Programs and the shell.run() Function
- What You Learned
- 7. Creating Modules to Reuse Your Code
-
8. Running an Automated Tree Farm
- Designing a Tree-Farming Program
- Writing the farmtrees Program
- Running the farmtrees Program
- Tree Types in Minecraft
- Chunk Loading in Minecraft
- Loading Modules with the os.loadAPI() Function
- Checking for Files with the fs.exists() Function
- Selecting Saplings in the Turtle’s Inventory
- Running Other Programs with the shell.run() Function
- Handling Items with the Turtle’s Drop Functions
- Rewriting Your Code for When You Have No Bone Meal
- What You Learned
-
9. Building a Cobblestone Generator
- Blueprints for the Cobblestone Generator
- Setting Up Furnaces for Smelting the Cobblestone
- Writing the cobminer Program
- Running the cobminer Program
- Setting Up Your Program and Making a Constant Variable
- Mining the Cobblestone from the Generator
- Interacting with Furnaces
- Moving the Cobblestone Miner Back into Position
- What You Learned
-
10. Making a Stone Brick Factory
- Designing a Program to Craft Stone Bricks
- Crafting a Crafty Turtle
- Writing the brickcrafter Program
- Running the brickcrafter Program
- Setup for the brickcrafter Program
- Checking the Turtle’s Fuel
- Collecting Stone from the Furnaces
- Crafting Stone Bricks
- Moving the Turtle Back into Position
- Creating a Factory Building
- What You Learned
- 11. Constructing Walls
- 12. Constructing Rooms
- 13. Constructing Floors
-
14. Programming a Robotic Farm
- Setting Up a Wheat Field
- Designing the Wheat-Farming Algorithm
- Extending the hare Module
- Writing the farmwheat Program
- Running the farmwheat Program
- Setup for the farmwheat Program
- Writing Functions to Use in the Main Program
- Farming with a Loop
- Tips for Automating Other Kinds of Farming
- What You Learned
-
15. Programming a Staircase Miner
- Designing the Stair-Mining Algorithm
- Extending the hare Module
- Writing the digUntilClear() and digUpUntilClear() Functions
- Writing the stairminer Program
- Running the stairminer Program
- Setup for the stairminer Program
- Creating the First Stair Step
- Mining Downward
- Checking the Turtle’s Fuel
- Checking the Turtle’s Inventory
- Mining Upward
- What You Learned
- Function Reference
- Name ID Reference
- INDEX
Product information
- Title: Coding with Minecraft
- Author(s):
- Release date: May 2018
- Publisher(s): No Starch Press
- ISBN: 9781593278533
You might also like
book
Learn to Program with Minecraft
Learn to Program with Minecraft is a kid-friendly introduction to customizing Minecraft with Python programming.
book
Adventures in Minecraft, 2nd Edition
Learn valuable programming skills while building your own Minecraft adventure! If you love playing Minecraft and …
book
Minecraft Modding with Forge
Playing Minecraft is a lot of fun, but the game is more engaging, entertaining, and educational …
book
Minecraft Modding For Kids For Dummies
Join more than 100 million players in the online world of Minecraft Are you a Minecraft …