Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------
- -- Functions --
- -----------------------------------------------------------------
- function checkFuel() --Fuel checking, refuels if able, gives error if no fuel.
- result = true
- while turtle.getFuelLevel() < 1 do
- result = false
- for i=2,16 do
- turtle.select(i)
- if turtle.refuel(1) then
- result = true
- break
- end
- end
- if not result then
- print " "
- print "Please add a fuel to slot 16"
- print "Press Enter when done."
- x = read()
- end
- end
- end
- function forward() --Move and Dig Forward
- checkFuel()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- function down() --Move and Dig Down
- checkFuel()
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- end
- function place() --Place stairs
- checkFuel()
- result = true
- if not turtle.detectDown() then
- result = false
- for i=2,16 do
- turtle.select(i)
- if turtle.getItemCount(15) >3 then
- result = true
- break
- end
- end
- end
- if not result then
- print " "
- print "Please add stairs."
- print "Press Enter when done."
- x = read()
- end
- --Place Middle
- turtle.select(15)
- turtle.turnRight()
- turtle.turnRight()
- turtle.placeDown()
- --Place Right
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.placeDown()
- --place Left
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.placeDown()
- --return mid
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function sides() --Clears Left and Right.
- turtle.turnLeft()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.turnRight()
- turtle.turnRight()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.turnLeft()
- end
- function Ret2strt() --Return to start
- checkFuel()
- turtle.up()
- turtle.back()
- end
- function firststeps()
- checkFuel()
- down()
- sides()
- turtle.up()
- place()
- end
- -----------------------------------------------------------------
- -- End Functions --
- -----------------------------------------------------------------
- print("How deep shall I go?")
- ammount = read() --read() is a function which returns text you entered.
- firststeps()
- for i=1, ammount do --Loop Start
- print("Doing run ", i," of ", ammount)
- checkFuel()
- turtle.up()
- turtle.up()
- turtle.up()
- --Digging
- forward()
- sides()
- down()
- sides()
- down()
- sides()
- down()
- sides()
- down()
- sides()
- down()
- sides()
- turtle.up()
- place()
- end
- print "Turtle done!"
- print "Going back."
- for i=1, ammount do
- Ret2strt()
- end
- print "All Done."
Advertisement
Add Comment
Please, Sign In to add comment