Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg1 = ...
- if arg1 == nil then
- print("miner <length>")
- return false
- end
- local length = tonumber(arg1)
- local delay = 0.25
- function forward()
- dig()
- turtle.forward()
- end
- function up()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(delay)
- end
- turtle.up()
- end
- function right(times)
- if times == nil then
- times = 1
- end
- for _ = 1, times do
- turtle.turnRight()
- end
- end
- function left(times)
- if times == nil then
- times = 1
- end
- for _ = 1, times do
- turtle.turnLeft()
- end
- end
- function dig()
- while turtle.detect() do
- turtle.dig()
- sleep(delay)
- end
- end
- function digRow()
- right()
- dig()
- left(2)
- dig()
- right()
- end
- local neededFuel = 2*length;
- local coal = math.ceil(neededFuel/80)
- if neededFuel > turtle.getFuelLevel() then
- turtle.select(1)
- print("Please put "..coal.." piece(s) of coal into slot 1")
- while neededFuel > turtle.getFuelLevel() do
- turtle.refuel()
- end
- end
- print("Digging...")
- for _ = 1, length do
- forward()
- digRow()
- up()
- digRow()
- turtle.down()
- end
- left(2)
- for _ = 1, length do
- turtle.forward()
- end
- if turtle.detect() then
- for i = 2, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- left(2)
- print("Done!")
- print("Rest fuel: "..turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement