# bar_x
def bar_x(x,y,z,length, material):
for i in range(x,x+length):
block(i, y, z, material)
# bar_y
def bar_y(x,y,z,length, material):
for j in range(y,y+length):
block(x, j, z, material)
# bar_z
def bar_z(x,y,z,length, material):
for k in range(z,z+length):
block(x, y, k, material)
# flat_xy
def flat_xy(x,y,z,h,w,m):
for j in range(y, y+h):
bar_x(x,j,z,w,m)
# flat_yz
def flat_yz(x,y,z,h,d,m):
for j in range(y, y+h):
bar_z(x,j,z,d,m)
# flat_xz, (roof)
def flat_xz(x,y,z,d,w,m):
for k in range(z, z+d):
bar_x(x,y,k,w,m)
# wall
def wall(x,z,h,w,m):
for i in range(x,(x+w)):
column(i,z,h,m)
# sideWall
def sideWall(x,z,h,w,m):
for k in range(z,z+w):
column(x,k,h,m)
3-09 Wall
Use block(), column()
to build a wall
# 3-03 block(x,y,z,material)
def block(x,y,z,material):
game.set_block(Position(x,y,z), materials[material])
# 3-08 Column
def column(x,z,height, material):
for j in range(1, height+1):
block(x,j,z, material)
# use column
# 3-09 wallX (use Column to build a wall)
def wallX(x,z,h,w,m):
"""To build a wall.
At (x,z) ground location, width w,height h and material m. x,z,w,h: integers, m is string."""
# add a note about DocString (Beginner Python 5.6)
for i in range(x,(x+w+1)):
column(i,z,h,m)
# 3-10 wallZ
def wallZ(x,z,h,w,m):
for k in range(z,z+w+1):
column(x,k,h,m)
wallZ(0,-10,10,6,'quartz')
wallZ(10,-10,10,6,'quartz')
wallX(0,-10,10,10,'brick')
3-11 horizontal line
Horizontal line is easy to achieve using block()
function from 3-03
# 3-03 block(x,y,z,material)
def block(x,y,z,material):
game.set_block(Position(x,y,z), materials[material])
# 3-11 X_line
def X_line(x,y,z,length, material):
for i in range(x, (x+length)):
block(i,y,z, material)
X_line(0,5,-10,5,'brick')
X_line(2,7,-10,5,'brick')
X_line(4,9,-10,5,'brick')
# 3-12 Z_line
def Z_line(x,y,z,length, material):
for k in range(z, (z+length)):
block(x,y,k, material)
Z_line(0,5,-9,5,'cobblestone')
Z_line(2,7,-9,5,'cobblestone')
Z_line(4,9,-9,5,'cobblestone')
# 3-13 Y_line
def Y_line(x,y,z,height, material):
for j in range(y, (y+height)):
block(x,j,z, material)
Y_line(0,6,-10,5,'obsidian')
Y_line(2,8,-10,5,'obsidian')
Y_line(4,10,-10,5,'obsidian')
3-14 Flat (use Z_line, Y_line)
# use Z_line(3-12):
# 3-14-1 roof_flat (loop Z-line)
def roof_flat(x,y,z,width,length,material):
for i in range(x,(x+width)):
Z_line(i,y,z,length,material)
roof_flat(0,10,-10,15,6,'diamond')
# 3-14-2 shelter
for i in [0,14]:
for k in [-10,-5]:
Column(i,k,10,'obsidian')
roof_flat(0,10,-10,15,6,'diamond')
# 3-14-3 stool
for i in [0,14]:
for k in [-10,-5]:
Column(i,k,40,'obsidian')
for j in range(10, 40,5):
roof_flat(0,j,-10,15,6,'diamond')
# 3-14-4 stairsToSky
for i in range(0,60,3):
roof_flat(i,i,-10,3,6, 'cobblestone')
# Use (3-13) Y_line:
# 3-14-5 flatX (vertical flat on x axis)
def flatX(x,y,z,h,w,m):
for i in range(x,(x+w)):
Y_line(i,y,z,h,m)
# 3-14-6 flatZ (vertical flat on z axis)
def flatZ(x,y,z,h,l,m):
for k in range(z,(z+l)):
Y_line(x,y,k,h,m)
# flatX(3,3,-10,5,10,'brick') # for testing
# flatZ(3,3,-10,8,8,'diamond')