Advertisement
edo_py

miningTurtle

Aug 4th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. local frontBlock = turtle.detect()
  2. local downBlock = turtle.detectDown()
  3. local upBlock = turtle.detectUp()
  4. local fuel = turtle.getFuelLevel()
  5. local modem = peripheral.wrap("back")
  6.  
  7. function dig(blocks, direction)
  8.   for e=1, blocks
  9.   do
  10.     if fuel >= 1
  11.     then
  12.       if direction == "in front"
  13.       then
  14.         turtle.dig()
  15.         turtle.forward()
  16.       elseif direction == "up"
  17.       then
  18.         turtle.digUp()
  19.         turtle.up()
  20.       elseif direction == "down"
  21.       then
  22.         turtle.digDown()
  23.         turtle.down()
  24.       end
  25.     else
  26.       modem.transmit(1, 2, "ERROR: MISSING FUEL")
  27.     end
  28.   end
  29.  
  30. function turn(times, direction2)
  31.   for x=1, times
  32.   do
  33.     if direction2 == "right"
  34.     then
  35.       turtle.turnRight()
  36.     elseif direction2 == "left"
  37.     then
  38.       turtle.turnLeft()
  39.     end
  40.   end
  41. end  
  42.  
  43. io.write("How many levels you want to excavate? \n"..
  44.          "(divide by two the levels you choose, it must be a whole number)\n")
  45. levels = io.read()
  46. if pcall((tonumber(levels)/2)
  47.   -- TUNNEL 2x2:
  48.   for i=1, levels/2
  49.    -- 1st level:
  50.   dig(20, "down")
  51.   dig(1, "in front")
  52.   turn(1, "right")
  53.   dig(1, "in front")
  54.   dig(1, "up")
  55.   turn(2, "left")
  56.   dig(1, "in front")
  57.   turn(1, "right")
  58.    -- 2nd level:
  59.   dig(1, "in front")
  60.   turn(1, "right")
  61.   dig(1, "in front")
  62.   dig(1, "down")
  63.   turn(2, "left")
  64.   dig(1, "in front")
  65.   turn(1, "right")
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement