edoreld

Untitled

Feb 4th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. args = {...}
  2. local distance = tonumber(args[1])
  3. local fuelSlot = 15
  4. local torchSlot = 16
  5.  
  6. function refuel()
  7.     while turtle.getFuelLevel() < 1000 do
  8.         term.clear()
  9.         print("This computer is running out of Fuel")
  10.         print("Looking for fuel in slot 15")
  11.         turtle.select(fuelSlot)
  12.         turtle.refuel()
  13.         turtle.select(1)
  14.         -- Fuel up
  15.         -- Include message when computer can't find fuel
  16.         os.sleep(1)
  17.     end
  18. end
  19.  
  20. function placeTorch()
  21.     turtle.select(16)
  22.     turtle.placeDown()
  23. end
  24.  
  25. function digForward()
  26.     refuel()
  27.     turtle.select(1)
  28.     while not turtle.forward() do
  29.         turtle.dig()
  30.     end
  31. end
  32.  
  33. function digBackward()
  34.     refuel()
  35.     turtle.select(1)
  36.     for i=1,2 do
  37.         turtle.turnLeft()
  38.     end
  39.     while not turtle.forward() do
  40.         turtle.dig()
  41.     end
  42. end
  43.  
  44. function digUp()
  45.     refuel()
  46.     turtle.select(1)
  47.     turtle.digUp()
  48. end
  49.  
  50. function digDown()
  51.     refuel()
  52.     turtle.select(1)
  53.     turtle.digDown()
  54. end
  55.  
  56. function digLeft()
  57.     refuel()
  58.     turtle.select(1)
  59.     turtle.turnLeft()
  60.     while not turtle.forward() do
  61.         turtle.dig()
  62.     end
  63. end
  64.  
  65. function digRight()
  66.     refuel()
  67.     turtle.select(1)
  68.     turtle.turnRight()
  69.     while not turtle.forward() do
  70.         turtle.dig()
  71.     end
  72. end
  73.  
  74. function digLine(direction)
  75.     if direction == "right" then
  76.         digForward()
  77.         turtle.turnRight()
  78.         for i=1,2 do
  79.             digUp()
  80.             digDown()
  81.             digForward()
  82.         end
  83.         digUp()
  84.         digDown()
  85.         turtle.turnLeft()
  86.  
  87.  
  88.     elseif direction == "left" then
  89.         digForward()
  90.         turtle.turnLeft()
  91.         for i=1,2 do
  92.             digUp()
  93.             digDown()
  94.             digForward()
  95.         end
  96.         digUp()
  97.         digDown()
  98.         turtle.turnRight()
  99.     end
  100. end
  101.  
  102. turtle.select(1)
  103.  
  104.  
  105. if #args == 0 then
  106.     distance = 1
  107. end
  108.  
  109. local j = 0
  110. for i=1,distance do
  111.     digLine("right")
  112.     if j % 4 == 0 then
  113.         placeTorch()
  114.     end
  115.     digLine("left")
  116.     j = j + 1
  117. end
Advertisement
Add Comment
Please, Sign In to add comment