Hardware Reference
In-Depth Information
Modify the demolishRoom() function to look like this.
def demolishRoom():
mc.setBlocks(roomx, roomy, roomz,
roomx+SIZEX+2, roomy+SIZEY+2, roomz+SIZEZ+2,
block.AIR.id)
Save your program and run it again. Now it's easy to build or demolish your duplicator
room. Just use option 1 on your menu to build it and option 7 to demolish it.
Scanning from.the Duplicator Room
You have written this part of the program before, in your scan3D.py program, so you
can use that with some small modifications.
1. Replace the scan3D() function with the following code. This code is almost
identical to the scan3D.py program, but the lines in bold have been added to
make it show the progress of the scanning on the Minecraft chat. Scanning a big
room can take a long time, so it is nice to have some indication of how far
through the process your program has got. You can use copy and paste to bring
in the code from your earlier program to save some typing time here:
def scan3D(filename, originx, originy, originz):
f = open(filename, "w")
f.write(str(SIZEX) + "," + str(SIZEY) + "," + str(SIZEZ)
+ "\n")
for y in range(SIZEY):
mc.postToChat("scan:" + str(y))
f.write("\n")
for x in range(SIZEX):
line = ""
for z in range(SIZEZ):
blockid = mc.getBlock(originx+x, originy+y,
originz+z)
if line != "":
line = line + ","
line = line + str(blockid)
f.write(line + "\n")
f.close()
2. Save the program and test it again by jumping into the duplicating room and
building something, then choosing option 3 from the menu. Open up the file
that it creates, to check that the object has been scanned properly. Figure 6-10
shows a portion of a scanned file. Note that there are lots of zeros; this is because
it has scanned all the AIR blocks as well.
 
 
Search WWH ::




Custom Search