Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local length = 0
- local currentFwd = 0
- local stopReason = ""
- function operationFinishMessage(reason)
- print("Operation has stopped.")
- os.sleep(1)
- print("Reason: ")
- os.sleep(2)
- print(reason)
- end
- function cls()
- term.clear()
- term.setCursorPos(1,1)
- end
- function craftDropOff()
- turtle.select(5)
- turtle.craft(turtle.getItemCount(5))
- --print("Crafted " .. tostring(turtle.getItemCount(5)) .. " " .. turtle.getItemDetail(5).name .. "(s).")
- end
- function move(direction)
- if direction == "forward" then
- return turtle.forward()
- elseif direction == "back" then
- return turtle.back()
- elseif direction == "up" then
- return turtle.up()
- elseif direction == "down" then
- return turtle.down()
- elseif direction == "left" then
- turtle.turnLeft()
- local success = turtle.forward()
- turtle.turnRight()
- return success
- elseif direction == "right" then
- turtle.turnRight()
- local success = turtle.forward()
- turtle.turnLeft()
- return success
- else
- print (direction .. " is not a valid direction!")
- return false
- end
- end
- function dig(direction)
- if direction == "forward" then
- return turtle.dig()
- elseif direction == "back" then
- turtle.turnRight()
- turtle.turnRight()
- local success = turtle.dig()
- turtle.turnRight()
- turtle.turnRight()
- return success
- elseif direction == "up" then
- return turtle.digUp()
- elseif direction == "down" then
- return turtle.digDown()
- elseif direction == "left" then
- turtle.turnLeft()
- local success = turtle.dig()
- turtle.turnRight()
- return success
- elseif direction == "right" then
- turtle.turnRight()
- local success = turtle.dig()
- turtle.turnLeft()
- return success
- else
- print (direction .. " is not a valid direction!")
- return false
- end
- end
- function excavate()
- cls()
- print("Starting excavation...")
- turtle.select(6)
- stopReason = "Movement blocked."
- while currentFwd <= length do
- dig("forward")
- if move("forward") == false then break end
- dig("right")
- dig("up")
- if move("up") == false then break end
- dig("right")
- dig("up")
- if move("up") == false then break end
- dig("right")
- if currentFwd % 2 == 0 then
- if move("down") == false then break end
- if move("down") == false then break end
- else
- if move("right") == false then break end
- if move("down") == false then break end
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.select(6)
- turtle.turnRight()
- if move("down") == false then break end
- if move("left") == false then break end
- end
- dig("down")
- if move("down") == false then break end
- dig("down")
- turtle.select(5)
- if turtle.placeDown() == false then
- stopReason = "Can't place drop off point."
- if move("up") == false then break end
- break
- end
- turtle.select(6)
- if move("up") == false then break end
- --Places dropOffPoint
- currentFwd = currentFwd + 1
- end
- if currentFwd >= length then stopReason = "Finished operation." end
- if turtle.getFuelLevel() <= 0 then stopReason = "Ran out of fuel." end
- cls()
- operationFinishMessage(stopReason)
- end
- function startExcavation()
- print("Tunnel Excavation")
- print("")
- print("Please read instructions.")
- print("Press enter...")
- read()
- cls()
- print("How far would you like to")
- print("excavate?")
- length = tonumber(read())
- cls()
- turtle.select(2)
- turtle.refuel()
- turtle.select(1)
- --Refuel.
- print("Turtle now has: ")
- print(tostring(turtle.getFuelLevel()) .. " fuel.")
- print(tostring(turtle.getItemCount(1)) .. " torches.")
- os.sleep(2)
- cls()
- local craftInputSuccessful = false
- while craftInputSuccessful == false do
- print("Would you like to craft")
- print("drop off points?")
- print("(yes/no)")
- local craftInputReturn = read()
- if craftInputReturn == "yes" then
- craftInputSuccessful = true
- cls()
- print("Crafting drop off points...")
- craftDropOff()
- elseif craftInputReturn == "no" then
- craftInputSuccessful = true
- else
- print("Please input either yes or no.")
- os.sleep(1)
- cls()
- end
- end
- os.sleep(2)
- excavate()
- end
- startExcavation()
Add Comment
Please, Sign In to add comment