Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local frontBlock = turtle.detect()
- local downBlock = turtle.detectDown()
- local upBlock = turtle.detectUp()
- local fuel = turtle.getFuelLevel()
- local modem = peripheral.wrap("back")
- function dig(blocks, direction)
- for e=1, blocks
- do
- if fuel >= 1
- then
- if direction == "in front"
- then
- turtle.dig()
- turtle.forward()
- elseif direction == "up"
- then
- turtle.digUp()
- turtle.up()
- elseif direction == "down"
- then
- turtle.digDown()
- turtle.down()
- end
- else
- modem.transmit(1, 2, "ERROR: MISSING FUEL")
- end
- end
- function turn(times, direction2)
- for x=1, times
- do
- if direction2 == "right"
- then
- turtle.turnRight()
- elseif direction2 == "left"
- then
- turtle.turnLeft()
- end
- end
- end
- io.write("How many levels you want to excavate? \n"..
- "(divide by two the levels you choose, it must be a whole number)\n")
- levels = io.read()
- if pcall((tonumber(levels)/2)
- -- TUNNEL 2x2:
- for i=1, levels/2
- -- 1st level:
- dig(20, "down")
- dig(1, "in front")
- turn(1, "right")
- dig(1, "in front")
- dig(1, "up")
- turn(2, "left")
- dig(1, "in front")
- turn(1, "right")
- -- 2nd level:
- dig(1, "in front")
- turn(1, "right")
- dig(1, "in front")
- dig(1, "down")
- turn(2, "left")
- dig(1, "in front")
- turn(1, "right")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement