Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Parameters
- local length = 10
- local width = 1
- local stepHeight = 3
- local direction = 1
- -- Variables
- local distance = 0
- write("Enter Length: ")
- length = tonumber(io.read()) or length
- print("Length set to " .. length)
- print("")
- write("Enter Width: ")
- width = tonumber(io.read()) or width
- print("Width set to " .. width)
- print("")
- write("Enter Step Height: ")
- stepHeight = tonumber(io.read()) or stepHeight
- print("Step Height set to " .. stepHeight)
- print("")
- print("Enter Direction")
- write("(0) left, (1) right: ")
- local dir = tonumber(io.read()) or direction
- local dirString = "none"
- if (dir == 0 or dir == 1) then
- direction = dir
- if (dir == 0) then
- dirString = "Left"
- else
- dirString = "Right"
- end
- end
- print("Direction set to " .. dirString)
- print("")
- -- Functions
- function Dig()
- while(turtle.detect()) do
- turtle.dig()
- sleep(0.5)
- end
- end
- function DigUp()
- while(turtle.detectUp()) do
- turtle.digUp()
- sleep(0.5)
- end
- end
- function DigDown()
- while(turtle.detectDown()) do
- turtle.digDown()
- sleep(0.5)
- end
- end
- function StepUp(move)
- DigUp()
- if (move) then
- turtle.up()
- end
- end
- function Step()
- Dig()
- turtle.forward()
- DigDown()
- for i = 1, stepHeight - 1 do
- if (i == stepHeight - 1) then
- StepUp(false)
- else
- StepUp(true)
- end
- end
- for i = 1, stepHeight do
- turtle.down()
- end
- distance = distance + 1
- end
- function StepBack()
- turtle.up()
- turtle.back()
- end
- function TurnStep()
- if (direction == 0) then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- Dig()
- turtle.forward()
- if (direction == 0) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- function NextLine()
- TurnStep()
- end
- -- Main
- for w = 1, width do
- for l = 1, length do
- Step()
- end
- for l = 1, length do
- StepBack()
- end
- if (width == 1) then
- break
- else
- if (w == width) then
- break
- else
- NextLine()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement