Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ################################
- -- boring by mining turtle
- -- version 0.3
- -- http://hevohevo.hatenablog.com/
- -- This Program requires a SilkTouch Mining Turtle by "More Turtles" mod
- -- "More Turtles" was created by Nokiyen.
- -- http://www.computercraft.info/forums2/index.php?/topic/16465-mc164152-more-turtles-v112/
- -- ########## config
- MIN_FUEL_LEVEL = 64 * 6 + 64 + 10
- CLOSE_HOLE_FLAG = true -- whether close a hole
- LID_BLOCK_SLOT = 1
- local args={...}
- -- reverse CLOSE_HOLE_FLAG
- if #args > 0 then CLOSE_HOLE_FLAG = not CLOSE_HOLE_FLAG end
- -- ########## functions
- local silkP = peripheral.wrap("right")
- if silkP and silkP.digSilkTouch then
- print("Boring with SilkTouch!")
- turtle.dig_org = turtle.dig_org or turtle.dig
- turtle.dig= silkP.digSilkTouch
- turtle.digDown_org = turtle.digDown_org or turtle.digDown
- turtle.digDown = silkP.digSilkTouchDown
- end
- function myRefuel()
- local function refuelAll()
- for i=1, 16 do
- turtle.select(i)
- turtle.refuel()
- end
- print("Fuel: ",turtle.getFuelLevel(), " (required: ",MIN_FUEL_LEVEL,")")
- end
- refuelAll()
- while turtle.getFuelLevel() < MIN_FUEL_LEVEL do
- os.sleep(1)
- -- wait for putting items in inventory
- os.pullEvent("turtle_inventory")
- refuelAll()
- end
- turtle.select(1)
- end
- Count = 0
- function revolve(depth)
- for i=1, 4 do -- dig four sides
- if turtle.dig() then Count=Count+1 end
- turtle.turnRight()
- end
- if turtle.digDown() then Count=Count+1 end
- if turtle.getFuelLevel() > depth + 10 then
- return turtle.down() -- return true/false
- else
- return false -- if fuel shortage
- end
- end
- function closeHole()
- turtle.select(LID_BLOCK_SLOT)
- turtle.down()
- for i=1,4 do
- turtle.place()
- turtle.turnRight()
- end
- turtle.up()
- turtle.placeDown()
- end
- function backToHome(n)
- for i=1, n do -- back to home position.
- turtle.up()
- end
- end
- -- ########## main
- myRefuel()
- if CLOSE_HOLE_FLAG then
- local err_msg = string.format("Insert 5 Lid-Blocks into slot %d",LID_BLOCK_SLOT)
- assert(turtle.getItemCount(LID_BLOCK_SLOT) >= 5, err_msg)
- end
- local depth = 0
- while revolve(depth) do
- print("Depth: ",depth)
- depth = depth +1
- end
- backToHome(depth)
- if CLOSE_HOLE_FLAG then closeHole() end
- print("Result: ",Count," blocks")
- print("Current Fuel: ",turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement