Hardware Reference
In-Depth Information
4. You are building a hollow cube with an open front, so put in three layers with
that format. Make sure you put a blank line before these numbers:
1,1,1,1,1
0,0,0,0,1
0,0,0,0,1
0,0,0,0,1
1,1,1,1,1
5. Use copy and paste to put in two more identical hollow layers below this one,
making sure you leave exactly one blank line between each square section of
numbers.
6. Finally, put a solid top on the object. To do this, use copy and paste to copy the
rows of data from step 3, again making sure that there is a blank line before the
first row of numbers of this layer.
Save your file, but don't run it—you can't run it as it is not a Python program but a
data file that will be used by the program you are now going to write.
Writing the.3D Printer
Now that you have written your test data, it is time to write the 3D printer program
that will build the hollow cave inside the Minecraft world. This program is very similar
to your maze program, but this one has three nested loops, one loop for each of the x,
y and z dimensions.
This is probably one of the most detailed programs you have written while
working through this topic. Work through it carefully, step by step, and you will
be amazed by the final results! If you get stuck, check your indents very carefully,
and remember that all of the program listings for all of the programs in this topic
are downloadable from the companion Wiley website at www.wiley.com/go/
adventuresinminecraft.
1. Start a new file with File New File, and use File Save As from the menu to
save it as print3D.py .
2. Import the necessary modules:
import mcpi.minecraft as minecraft
import mcpi.block as block
3. Connect to the Minecraft game:
mc = minecraft.Minecraft.create()
 
 
Search WWH ::




Custom Search