? A few things / Simple structures
not edited
stage??
Apply the bars and flats in CodeCraft
We will demo some applications of the bars and flats, if you'd like to design some other structures that need to call a function previously defined, make sure you have it at the beginning part of the file.
Example 1, use for
loop
This should be easy to understand:
# stairsToSky (cobblestone)
for i in range(0,60,3):
flat_xz(i,i,-10,3,6, 2)
((?? should we put pictures and hide the code??
# Understand nested loops
for j in range(0,10,2):
block(0, j+1, -20, 71)
for j in range(0,10,2):
for i in range (-j, j+1, 2):
block(i-20,j+1,-20, 69)
for j in range(0,10,3):
for i in range (-j, j+1, 3):
for k in range(-j, j+1, 3):
block(i-20,j+1,k+40, 76)
Example 4 Pyramid
for i in range(10):
flat_xz(i,i,-20+i, 20-2*i, 20-2*i, 1)
Building
for i in range(20,30):
for j in range(1,12, 2):
for k in range(-20, -10, 2):
block(i, j, k, 2)
block(i, j+1, k, 3)
Use list
Example 3
List is useful to store some locations. Use lists and call column(x,z,h,m)
and flat_xz(x,y,z,d,w,m)
functions to build:
# shelter
for i in [0,14]:
for k in [-10,-5]:
column(i,k,10,'obsidian')
flat_xz(0,10,-10,15,6,'diamond')
# book shelf
for i in [0,14]:
for k in [-10,-5]:
column(i,k,40,'obsidian')
for j in range(10, 40,5):
flat_xz(0,j,-10,15,6,'diamond')
((not edited))
HiLow columns
# HiLow columns(n)
def HiLowColA(n):
for i in range(1, 2*n, 2):
column(i, -20, (2*n-i) , 'red_sandstone')
column((i+2*n), -20, i , 'red_sandstone')
HiLowColA(10)
# HiLow columns(n) at starting location m*40
def HiLowColB(n,m):
for i in range(1, 2*n, 2):
column((i+m*40), -15, (2*n-i), 'obsidian')
column((i+2*n+m*40), -15, i , 'obsidian')
# One set will make the same number of columns as HiLowColA(10), we change z location and material to be black obsidian
HiLowColB(10, 1) # One set will make the same number of columns as HiLowColA(10), we change z location and material to be black obsidian
# Now make 3 sets of HiLow columns:
for t in range(3):
HiLowCol(10,t)
# 3-07-3 GoldenGate
def HiLowColC(n,m,z):
for i in range(1, 2*n, 3):
column((i+m*40), z, (2*n-i), 'red_sandstone')
column((i+2*n+m*40), z, i , 'red_sandstone')
for t in range(3):
HiLowColC(10,t,-20)
HiLowColC(10,t,-40)
# Floor board, flat_xz(x,y,z,width,length,material)
flat_xz(1,1, -40, 20, 60,'cobblestone')