Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- exercise5_2
- -- surround four directions with walls
- -- ####### Define a function ########
- function placeSomeBlocks(n)
- for i=1,n do
- turtle.forward() -- move to next position
- turtle.placeDown() -- put a block in the ground
- end
- end
- -- 一辺の長さが nagasa の正方形を作る
- function makeSquare(nagasa)
- -- たとえば一辺7の正方形ならば、6個設置を4回繰り返す
- for i=1,4 do
- placeSomeBlocks(nagasa - 1)
- turtle.turnRight()
- end
- end
- -- 天井を作る
- function makeCeiling()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- makeSquare(5)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- makeSquare(3)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.placeDown()
- end
- -- ###### Main ########
- turtle.select(1) -- the usual phrase
- turtle.up() -- move up
- -- stack six squares
- for ronoji=1,6 do
- -- 1st stage is made with slot 1, 2nd stage is slot 2, ...
- turtle.select(ronoji)
- -- make 4 sides of a square
- makeSquare(7)
- turtle.up() -- move up
- end
- turtle.down()
- makeCeiling()
Add Comment
Please, Sign In to add comment