Coding with minecraft build taller, farm faster, mine deeper, and automate the boring stuff

254 290 0
Coding with minecraft  build taller, farm faster, mine deeper, and automate the boring stuff

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CODING WITH MINECRAFT® BUILD TALLER, FARM FASTER, MINE DEEPER, AND AUTOMATE THE BORING STUFF BY AL SWEIGART San Francisco CODING WITH MINECRAFT Copyright © 2018 by Al Sweigart All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-10: 1-59327-853-5 ISBN-13: 978-1-59327-853-3 Publisher: William Pollock Production Editor: Laurel Chun Cover Illustration: Josh Ellingson Developmental Editor: Jan Cash Technical Reviewer: Daniel Ratcliffe Copyeditor: Anne Marie Walker Compositor: Meg Sneeringer Proofreader: Shannon Waite For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc directly: No Starch Press, Inc 245 8th Street, San Francisco, CA 94103 phone: 1.415.863.9900; info@nostarch.com www.nostarch.com Library of Congress Cataloging-in-Publication Data Names: Sweigart, Al, author Title: Coding with Minecraft: build taller, farm faster, mine deeper, and automate the boring stuff / Al Sweigart Description: San Francisco : No Starch Press, Inc., [2018] | Includes index Identifiers: LCCN 2017046330 (print) | LCCN 2017058488 (ebook) | ISBN 9781593278540 (ebook) | ISBN 1593278543 (ebook) | ISBN 9781593278533 (pbk.) | ISBN 1593278535 (pbk.) Subjects: LCSH: Minecraft (Game) | Lua (Computer program language) | Computer programming Classification: LCC GV1469.35.M535 (ebook) | LCC GV1469.35.M535 S94 2018 (print) | DDC 794.8 dc23 LC record available at https://lccn.loc.gov/2017046330 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc Other product and company names mentioned herein may be the trademarks of their respective owners Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Minecraft is a registered trademark of Mojang Synergies AB, which does not authorize or endorse this book The information in this book is distributed on an “As Is” basis, without warranty While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it To Daniel Ratcliffe, the ComputerCraft creator, and Seymour Papert, the turtle creator ABOUT THE AUTHOR Al Sweigart is a professional software developer who teaches programming to kids and adults Sweigart has written several bestselling programming books for beginners, including Automate the Boring Stuff with Python, Invent Your Own Computer Games with Python, and Cracking Codes with Python (all from No Starch Press) His books are freely available under a Creative Commons license at https://inventwithpython.com/ ABOUT THE TECHNICAL REVIEWER Daniel Ratcliffe is a game developer from Cambridge, England He created the ComputerCraft mod for Minecraft in 2011 and has been making games since 2002 You can read about his latest projects on Twitter, @DanTwoHundred His other interests include Star Trek, cycling, and cats BRIEF CONTENTS Acknowledgments Introduction Chapter 1: Getting Started with ComputerCraft Chapter 2: Programming Basics Chapter 3: Talking to Your Turtle Chapter 4: Programming Turtles to Dance Chapter 5: Making a Better Dancer Chapter 6: Programming a Robot Lumberjack Chapter 7: Creating Modules to Reuse Your Code Chapter 8: Running an Automated Tree Farm Chapter 9: Building a Cobblestone Generator Chapter 10: Making a Stone Brick Factory Chapter 11: Constructing Walls Chapter 12: Constructing Rooms Chapter 13: Constructing Floors Chapter 14: Programming a Robotic Farm Chapter 15: Programming a Staircase Miner Function Reference Name ID Reference Index 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 GETTING STARTED WITH COMPUTERCRAFT Installing Minecraft, ATLauncher, and ComputerCraft Buying Minecraft Online Downloading and Installing ATLauncher Downloading and Installing ComputerCraft Running Minecraft Creating a New World Minecraft Game Mode Differences What You Learned PROGRAMMING BASICS Getting Started with Turtles Crafting a Mining Turtle Running Programs in the Turtle GUI Fueling the Turtle Moving the Turtle Getting Started with Lua Programming Running the Lua Shell Goodbye Lua: Exiting Lua’s Prompt Letting Lua Do the Math Order of Operations That’s So Random: Generating Random Numbers Storing Values with Variables Checking the Turtle’s Fuel Levels What You Learned TALKING TO YOUR TURTLE Teaching Your Turtle to Say Hello! Running the hello Program Listing All Files with the ls Command Displaying Text with the print() Function The String Data Type Stringing Strings Together with Concatenation Retrieving Turtle Names Getting Keyboard Input with the io.read() Function Bonus Activity: Proper Introductions Giving Text a Typewriter Effect Changing Turtle Names Bonus Activity: A Turtle by Any Other Name What You Learned 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 Bonus Activity: New Dance Moves Sharing and Downloading Programs Online Deleting Files Off the Turtle pastebin.com Limitations turtleappstore.com Bonus Activity: Maze Runner What You Learned 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! Moving Up and Down Spinning All Around Bonus Activity: Watchturtle What You Learned 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 The not Boolean Operator The and Boolean Operator The or Boolean Operator 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 Bonus Activity: Going Down What You Learned CREATING MODULES TO REUSE YOUR CODE Creating Functions with the function Statement Arguments and Parameters Return Values Making a Module of Functions Loading a Module with the os.loadAPI() Function Experimenting with the hare Module Looking at the Turtle’s Inventory Selecting an Inventory Slot Counting the Number of Items in a Slot Getting Item Details from a Slot The Table Data Type .. .CODING WITH MINECRAFT BUILD TALLER, FARM FASTER, MINE DEEPER, AND AUTOMATE THE BORING STUFF BY AL SWEIGART San Francisco CODING WITH MINECRAFT Copyright © 2018 by... Cataloging-in-Publication Data Names: Sweigart, Al, author Title: Coding with Minecraft: build taller, farm faster, mine deeper, and automate the boring stuff / Al Sweigart Description: San Francisco : No... 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

Ngày đăng: 04/03/2019, 10:26

Từ khóa liên quan

Mục lục

  • 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

Tài liệu cùng người dùng

Tài liệu liên quan