Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function moveDown(blocks)
- for i=1,blocks do
- turtle.down()
- end
- end
- function digAllUp()
- local i = 0
- while (turtle.detectUp()) do
- i = i + 1
- turtle.digUp()
- turtle.up()
- end
- return i
- end
- function digAllDown(blocks)
- for i=1,blocks do
- turtle.digDown()
- turtle.down()
- end
- end
- function digAllLine(amount)
- --dig up then dig down, and if theres an odd number go down when your done
- local j = 0
- for i=1,amount do
- if (i % 2 == 0) then
- digAllDown(j)
- else
- j = digAllUp()
- end
- turtle.dig()
- turtle.forward()
- end
- if(amount % 2 == 1) then
- moveDown(j)
- end
- end
- function turnNum(num)
- if (num == 1) then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- function main(width, length)
- local side = 1
- for i=1,length do
- digAllLine(width)
- turnNum(side)
- side = side * -1
- end
- end
- print("width(forward):")
- local width = tonumber(read())
- print("length(right):")
- local length = tonumber(read())
- main(width, length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement