Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Functions.
- function digSuckMove(direction)
- if direction == "up" then
- if turtle.detect() == true then
- print("Block above! Mining, picking up and moving up!")
- turtle.digUp()
- turtle.suckUp()
- turtle.up()
- else
- print("Nothing above! Moving up!")
- turtle.up()
- end
- elseif direction == "down" then
- if turtle.detectDown() == true then
- print("Block below! Mining, picking up and moving down!")
- turtle.digDown()
- turtle.suckDown()
- turtle.Down()
- else
- print("Nothing below! Moving down!")
- turtle.Down()
- end
- elseif direction == "forward" then
- if turtle.detect() == true then
- print("Block in front! Mining, picking up and moving forward!")
- turtle.dig()
- turtle.suck()
- turtle.forward()
- else
- print("Nothing in front! Moving forward!")
- turtle.forward()
- end
- else
- print("Invalid argument!")
- end
- end
- function returnToStart()
- for i3 = 1, cycleCount, 1 do
- turtle.back()
- end
- end
- -- Read the cycle count.
- local cycleCount
- local inFront, blockInfo = turtle.inspect()
- print("How many cycles to run?")
- cycleCount = read()
- -- Run the cycle.
- for i = 1, cycleCount, 1 do
- -- Print the current cycle number.
- print("Running cycle number "..i..".")
- digSuckMove('Forward')
- digSuckMove("Up")
- digSuckMove("Up")
- turtle.turnLeft()
- for i2 = 1, 3, 1 do
- turtle.dig()
- turtle.down()
- end
- turtle.turnRight()
- turtle.turnRight()
- for i2 = 1, 3, 1 do
- turtle.dig()
- turtle.up()
- end
- turtle.down()
- turtle.down()
- -- End of for.
- end
- print("Run completed successfuly! Returning to base!")
- returnToStart()
- print("Returned to starting position! Press any button to clear screen!");
- os.pullEvent('key')
- term.clear()
- term.setCursorPos(1,1)
- -- Prevent instant termination.
- -- read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement