Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
Title Page
Copyright Page
Dedication
About the Author
About the Technical Reviewer
Brief Contents
Contents in Detail
Acknowledgments
Introduction
What Are Minecraft Mods?
What Is ComputerCraft?
How to Use This Book
What’s in This Book?
Getting Help
Online Resources
What You Learned
1. Getting Started with ComputerCraft
Installing Minecraft, ATLauncher, and ComputerCraft
Running Minecraft
What You Learned
2. Programming Basics
Getting Started with Turtles
Getting Started with Lua Programming
Letting Lua Do the Math
Storing Values with Variables
Checking the Turtle’s Fuel Levels
What You Learned
3. Talking to Your Turtle
Teaching Your Turtle to Say Hello!
Displaying Text with the print() Function
Retrieving Turtle Names
Getting Keyboard Input with the io.read() Function
Giving Text a Typewriter Effect
Changing Turtle Names
What You Learned
4. Programming Turtles to Dance
Writing a Dance Program
Running the mydance Program
Using Comments in Your Code
Turtle Movement Functions
Experimenting with Moving the Turtle
Looping with for Loops
Taking the Turtle for a Spin
Doing a Little Hop
Sharing and Downloading Programs Online
What You Learned
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
Creating Functions with the function Statement
Making a Module of Functions
Looking at the Turtle’s Inventory
Global and Local Scope
Finding an Item with a for Loop
Selecting an Empty Inventory Slot
What You Learned
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
Extending the hare Module
Writing and Running the buildwall Program
Loading the hare Module
Using the Array Data Type
Reading Command Line Arguments
Creating Usage Messages
Calling hare.buildWall() to Build a Wall
What You Learned
12. Constructing Rooms
Designing a Room-Building Algorithm
Extending the hare Module
Calculating the Total Number of Blocks Needed to Build a Room
Writing the buildRoom() Function
Writing the buildroom Program
Running the buildroom Program
What You Learned
13. Constructing Floors
Designing the Sweeping Algorithm
Passing Functions to Functions
Extending the hare Module
Calling the sweepFunc() Function
Writing the buildFloor() Function
Writing the buildfloor Program
Running the buildfloor Program
Creating a Patterned Floor
What You Learned
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
fs (File System) API
hare API
io (Input/Output) API
math API
os (Operating System) API
shell API
string API
textutils API
turtle API
Lua Functions
Name ID Reference
Finding a Block’s Name ID
Distinguishing Between Blocks That Share Name IDs
List of Block Name IDs
INDEX
← Prev
Back
Next →
← Prev
Back
Next →