Hardware Reference
In-Depth Information
Building a Duplicating Machine
You now have all the building blocks of programs you need in order to design and build
your own 3D duplicating machine that will be envy of all your friends. With it, you will
be able to jump into the Minecraft world and make a magic duplicating room materi-
alise, in which you can build any object you like. You can then save these objects to
files, load them back into the room to edit them or magically duplicate them all over
the Minecraft world. Finally, you can escape from the world and make the duplicating
room vanish completely, leaving no traces of your magic behind you.
Just like in some of the earlier adventures, you are going to use your existing programs
and stitch them together into a much bigger program. Because this program has a
number of features, you are going to add a menu system to it so it is easy to control.
Writing the.Framework of.the
Duplicating Machine Program
The first thing to do is to write the framework of the program that makes it all hang
together. You will start with some dummy functions that just print their name when
you call them, and gradually fill in their detail using your existing functions from other
programs. You may remember that this is the same way you built up your treasure
hunt game in Adventure 4?
1. Start a new file with File New File and save it as duplicator.py .
2. Import the necessary modules:
import mcpi.minecraft as minecraft
import mcpi.block as block
import glob
import time
import random
3. Connect to the Minecraft game:
mc = minecraft.Minecraft.create()
4. Set some constants for the size of your duplicating machine. Don't set these too
big, or the duplicator will take too long to scan and print objects. Also set an
initial default position for your duplicating room:
SIZEX = 10
SIZEY = 10
SIZEZ = 10
roomx = 1
roomy = 1
roomz = 1
 
 
Search WWH ::




Custom Search