Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length = 600
- refuel_value = 2
- -- If an additional argument is given, it will be used as length for the tunnel
- --if #arg > 2 then
- -- length = tonumber(arg[2])
- --end
- function dig_full()
- refuelTurtle()
- for i = 1, length do
- if turtle_is_full() then
- return_to_chest(i)
- else
- dig_forward()
- end
- end
- print('returning to chest')
- print(length)
- -- turn around
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, length do
- refuelTurtle()
- turtle.forward()
- end
- -- make sure that the turtle is in front of a chest
- while not turtle.detect() do
- turtle.forward()
- end
- emptyInventory()
- end
- function return_to_chest(nr_blocks)
- print('returning to chest')
- print(nr_blocks)
- -- turn around
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, nr_blocks do
- refuelTurtle()
- turtle.forward()
- end
- -- make sure that the turtle is in front of a chest
- while not turtle.detect() do
- turtle.forward()
- end
- emptyInventory()
- -- turn around
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, nr_blocks do
- refuelTurtle()
- turtle.forward()
- end
- end
- function emptyInventory()
- for i = 2, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function turtle_is_full()
- return turtle.getItemCount(16) > 0
- end
- function dig_small_tunnel()
- dig_forward()
- dig_down()
- dig_up()
- end
- function dig_up()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- end
- function dig_down()
- while turtle.detectDown() do
- turtle.digDown()
- end
- turtle.down()
- end
- function dig_forward()
- while turtle.detect() do
- turtle.dig()
- end
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- refuelTurtle()
- turtle.forward()
- end
- function refuelTurtle()
- -- coal has a burn value of 80, below 40 means than only half a coal is left
- if turtle.getFuelLevel() < 40 then
- print('Fuel value below 40, trying to refuel...')
- local success = turtle.refuel(refuel_value)
- if success then
- print('Refueled successfully')
- end
- end
- end
- print('starting to dig')
- dig_full()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement