Hardware Reference
In-Depth Information
program statements together. You have to be extra-careful with Python inden-
tation as a result; otherwise your program will not work properly!
Most of the time, Python does not allow you to split long lines, which is why in
this topic you will often see the arrow instructing you that this is a long line
that should not be broken.
However, there are two other ways in Python that you can cope with long lines.
Firstly, you can use a line continuation character—if the last character at the end of
a line is a backslash character (like this: \ ) then you can continue on the next line.
a = 1
if a == 1 or \
a == 2:
print("yes")
The second method that you can sometimes use to split long lines is to split
them at a point where it is obvious to Python that the line has not finished. For
example, if you are setting initial values in a list, or using a function, you can
break the lines when Python knows from the other parts of the line that there
must be more code to follow. Here are two examples of where Python allows
you to split a long line into shorter lines, because the open brackets tell Python
that the line has not finished until a matching close bracket is seen:
names = ["David",
"Steve",
"Joan",
"Joanne"
]
mc.setBlocks(x1, y1, z1,
x2, y2, z2, block.AIR.id)
Demolishing the.Duplicator Room
When you have run your duplicator program many times, you will probably end up
with lots of old duplicator rooms built all over the Minecraft world. Only the latest one
that you have created is actually a working room, and after some time your world will
fill up so much that you won't know which room is the right one! To solve this prob-
lem, you will now add a feature to your program that demolishes the duplicator room
so that your Minecraft world doesn't get cluttered with all these old rooms!
Demolishing the duplicator room is just like using your clearSpace.py program
from Adventure 3. All you need to know is the outer coordinates of the room. Because
the room is one block bigger all around the outside of the duplicating space defined by
SIZEX , SIZEY and SIZEZ , this is quite simple to do with a little bit of maths.
 
Search WWH ::




Custom Search