Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ################################
- -- Boring by mining turtle
- -- version 0.2
- -- http://hevohevo.hatenablog.com/
- -- ########## config
- MIN_FUEL_LEVEL = 400
- CLOSE_HOLE_FLAG = true -- boolean. 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
- 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
- function revolve(depth)
- for i=1, 4 do -- dig four sides
- turtle.dig()
- turtle.turnRight()
- end
- turtle.digDown() -- dig down side
- if turtle.getFuelLevel() > depth 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()
- local depth = 0
- while revolve(depth) do
- depth = depth +1
- end
- backToHome(depth)
- if CLOSE_HOLE_FLAG then closeHole() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement