Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Digs a 3x3 hole to a user specified depth. 99% guarenteed to not lose anything.
- -- requirements: 2 identical storage devices (chests, enderchests, diamond chests, ect), fuel, mining turtle.
- local downs = 0
- local ups = 1
- local refuelcounts = 0
- function threesquare() --mine a 3x3 square directly around the turtle
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- depth()
- end
- function refueltry (n) -- how many times have we tried to refuel
- n = n or 1
- refuelcounts = refuelcounts + n
- end
- function refuel()
- while turtle.getFuelLevel() < 130 do --130 fuel allows to dig to bedrock from approximatley z=119.
- turtle.select(15) -- keep fuel of some kind in this slot
- turtle.refuel(1)
- turtle.select(1)
- refueltry() --keep track of how many times we've tried to refuel
- if refuelcounts > 30 then --The weakest fuel, sticks, has 5 fuel value. Filling from 0 to 130 is 26 sticks, if the counter reaches 30 it means we have no fuel.
- error("You must provide aditional fuel\n")
- break
- end
- end
- end
- function dropall() --drop all the shit we just collected
- turtle.select(1)
- turtle.drop()
- turtle.select(2)
- turtle.drop()
- turtle.select(3)
- turtle.drop()
- turtle.select(4)
- turtle.drop()
- turtle.select(5)
- turtle.drop()
- turtle.select(6)
- turtle.drop()
- turtle.select(7)
- turtle.drop()
- turtle.select(8)
- turtle.drop()
- turtle.select(9)
- turtle.drop()
- turtle.select(10)
- turtle.drop()
- turtle.select(11)
- turtle.drop()
- turtle.select(12)
- turtle.drop()
- turtle.select(13)
- turtle.drop()
- turtle.select(14)
- turtle.drop()
- turtle.select(1)
- end
- function depth (n) -- how deep has the turtle gone
- n = n or 1
- downs = downs + n
- end
- function dive()
- for d=1,ups do
- turtle.digDown()
- turtle.down()
- end
- threesquare()
- end
- function surface() --however deep we went now we gotta go back up the same number of times
- for i=1,downs do
- turtle.up()
- end
- deeper()
- end
- function deeper (n)
- n = n or 1
- ups = ups + n
- end
- write("How Deep? ")
- local howdeep = io.read()
- for q=1,howdeep do
- refuel() -- if we don't refuel here the turtle will start diving where it's placed and then go haywire when told to go "back" where the chest is supposed to be
- refuelcounts = 0 -- set the refuel atempt counter back to 0 so it doesn't eff up subsequent refuelings.
- turtle.forward()
- turtle.forward()
- refuel()
- refuelcounts = 0
- dive() -- handles counting how far down we need to go/have gone, calls the 3x3 digging function.
- refuel()
- refuelcounts = 0
- surface()
- turtle.back()
- turtle.back()
- turtle.turnRight() --place some kind of storage (chest, enderchest, diamond chest, whatever) on the right side of the turtle where it starts.
- turtle.select(16) -- place the same kind of storage in slot 16
- local chestfound = turtle.compare() -- make sure we're at a chest so we don't dump stuff in lava or whatever, just in case we got off course.
- if chestfound == true then
- dropall()
- else
- error("missing deposit chest\n") -- 99% of the time this means you forgot to put a chest to the right of the turtle. 1% of the time there's actually an issue
- break
- end
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment