Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle Tunnel v2
- -- Various improvements
- -- TODO: Implement offset.
- -- TODO: Implement z-axis.
- -- TODO: Implement chest drop off and
- -- calculate fuel used.
- -- TODO: More updates to screen when running.
- -- TODO: Implement different modes (Make stairs,
- -- mine for ore, quarry, etc.
- -- FIX: Incorrect percentages
- -- FIX: Odd number of on y axis goes back
- -- 1 space too far
- xoffset = "left"
- x = 0
- y = 0
- z = 0
- neededFuel = 0
- blockNum = 0
- termColorDefault = 1
- termColorAlert = 1 -- 16384 Color not supported :c
- function Intro()
- term.clear()
- term.setCursorPos(1,1)
- print("From where the turtle is placed, which way do you want it to go?")
- term.setTextColor(termColorAlert)
- print("right/left:")
- term.setTextColor(termColorDefault)
- xoffset = string.lower(io.read())
- while xoffset ~= "right" and xoffset ~= "left" do
- print("You must type 'right' or 'left' without the quotes")
- term.setTextColor(termColorAlert)
- print("right/left:")
- term.setTextColor(termColorDefault)
- xoffset = string.lower(io.read())
- end
- print()
- print("How far to the ",xoffset," will the turtle go?:")
- term.setTextColor(termColorAlert)
- print("Enter number:")
- term.setTextColor(termColorDefault)
- x = tonumber(io.read())
- while not x do
- term.setTextColor(termColorAlert)
- print("You must enter a number:")
- term.setTextColor(termColorDefault)
- x = tonumber(io.read())
- end
- print()
- print("How far forward will the turtle go?:")
- term.setTextColor(termColorAlert)
- print("Enter number:")
- term.setTextColor(termColorDefault)
- y = tonumber(io.read())
- while not y do
- term.setTextColor(termColorAlert)
- print("You must enter a number:")
- term.setTextColor(termColorDefault)
- y = tonumber(io.read())
- end
- print()
- neededFuel = x*y+(y+2)
- -- Checks turtle fuel level
- while turtle.getFuelLevel() < neededFuel do
- term.clear()
- term.setCursorPos(1,1)
- print("Your turtle doesn't have enough fuel to go the specified distance")
- print("Current fuel: ", turtle.getFuelLevel())
- print("Needed fuel: ", neededFuel)
- print("Would you like to add fuel now?")
- print("y/n")
- input = string.lower(io.read())
- while input ~= "y" and input ~= "yes" and input ~= "n" and input ~= "no" do
- print("y/n")
- input = string.lower(io.read())
- end
- if input == "y" or input == "yes" then
- print("Add fuel to turtle inventory, then press enter")
- print("This will consume all fuel in turtle")
- io.read()
- for i = 1, 16 do
- turtle.select(i)
- turtle.refuel()
- end
- turtle.select(1)
- else
- break
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Your turtle will go ",x," blocks to the ",xoffset," and ",y," blocks forward.")
- print("Current fuel: ",turtle.getFuelLevel())
- print("Needed fuel: ",neededFuel)
- print("Is this correct?")
- term.setTextColor(termColorAlert)
- print("y/n:")
- term.setTextColor(termColorDefault)
- input = string.lower(io.read())
- while input ~= "y" and input ~= "yes" and input ~= "n" and input ~= "no" do
- term.setTextColor(termColorAlert)
- print("y/n:")
- term.setTextColor(termColorDefault)
- input = string.lower(io.read())
- end
- if input == "y" or input == "yes" then
- -- UpdateScreen(0)
- --Starting to mine!
- MineTunnel()
- -- UpdateScreen(y)
- elseif input == "n" or input == "no" then
- print("Try again?")
- term.setTextColor(termColorAlert)
- print("y/n:")
- term.setTextColor(termColorDefault)
- input = string.lower(io.read())
- while input ~= "y" and input ~= "yes" and input ~= "n" and input ~= "no" do
- term.setTextColor(termColorAlert)
- print("y/n")
- term.setTextColor(termColorDefault)
- input = string.lower(io.read())
- end
- if input == "y" or input == "yes" then
- Intro()
- else
- --Closes program
- error()
- end
- end
- end
- -- Movement loop
- function SafeMove(blockNum, mineAround)
- for i = 1, blockNum do
- if mineAround then
- turtle.digUp()
- turtle.digDown()
- end
- while not turtle.forward() do
- if turtle.detect() then
- turtle.dig()
- else
- turtle.attack()
- end
- end
- -- UpdateScreen()
- blockNum = blockNum + 1
- UpdateScreen()
- end
- end
- function MineTunnel()
- while not turtle.up() do
- turtle.digUp()
- end
- -- turtle.digUp()
- -- turtle.up()
- for i = 1, y/2 do
- SafeMove(1, false)
- turtle.turnLeft()
- turtle.digUp()
- turtle.digDown()
- SafeMove(x-1, true)
- turtle.turnRight()
- turtle.digUp()
- turtle.digDown()
- SafeMove(1, false)
- turtle.turnRight()
- turtle.digUp()
- turtle.digDown()
- SafeMove(x-1, true)
- turtle.turnLeft()
- turtle.digUp()
- turtle.digDown()
- UpdateScreen(i*2)
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- SafeMove(y, false)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function DropItems()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function StairsMode()
- end
- --function UpdateScreen(percent)
- function UpdateScreen()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(termColorAlert)
- print("Turtle Activated")
- term.setTextColor(termColorDefault)
- -- print(percent/y*100, "% completed")
- print(blockNum/neededFuel, "% completed")
- print("Fuel Level: ", turtle.getFuelLevel())
- end
- Intro()
- --turtle.forward()
- --turtle.forward()
- --turtle.forward()
- --turtle.forward()
- --turtle.forward()
- --SafeMove(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement