Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Direction enums
- LEFT = 0
- RIGHT = 1
- function go(dir, n)
- -- goes n blocks in direction dir
- -- ends facing direction dir
- if dir == LEFT then
- turtle.turnLeft()
- elseif dir == RIGHT then
- turtle.turnRight()
- else
- print("Invalid direction: '" .. dir .. "'")
- return
- end
- for i = 1,n do
- turtle.forward()
- end
- end
- function getBlock()
- -- ensures turtle always has selected block
- while(true) do
- if turtle.getItemCount() == 0 then
- i = turtle.getSelectedSlot()
- turtle.select(i+1)
- else
- break
- end
- end
- end
- function buildLine(length)
- -- builds a line of blocks below the turtle
- for i = 1,length do
- getBlock()
- turtle.placeDown()
- turtle.forward()
- end
- end
- function bigSlice(n)
- -- counter clockwise
- for i = 1,n do
- for j = 1,4 do
- buildLine(4)
- turtle.forward()
- go(LEFT, 1)
- turtle.turnRight()
- buildLine(2)
- turtle.forward()
- go(LEFT, 1)
- turtle.turnRight()
- buildLine(1)
- turtle.forward()
- go(LEFT, 1)
- buildLine(2)
- go(LEFT, 1)
- go(LEFT, 1)
- end
- end
- end
- bigSlice(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement