SamuelHurst

CC Tunnel

Dec 29th, 2020 (edited)
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. -- definitions
  2.  
  3. function checkLavaAndFuel()
  4.     local fuelLimit = turtle.getFuelLimit()
  5.     if turtle.getFuelLevel() < fuelLimit - 1000 then
  6.         turtle.select(15)
  7.         if turtle.place() then
  8.             if not turtle.refuel() then
  9.                 -- we picked up something other than lava (water, etc.)
  10.                 turtle.place()
  11.             end
  12.         end
  13.     end
  14. end
  15.  
  16. function autoRefuel()
  17.     checkLavaAndFuel()
  18.     local fuelLimit = turtle.getFuelLimit()
  19.     while turtle.getFuelLevel() < 80 do
  20.         turtle.select(16)
  21.         if turtle.refuel(0) then
  22.             -- we can refuel using slot 16
  23.             turtle.refuel(1)
  24.         end
  25.     end
  26. end
  27.  
  28. function isFull()
  29.     if turtle.getItemCount(12) > 0 then
  30.         return true
  31.     else
  32.         return false
  33.     end
  34. end
  35.  
  36. -- start
  37. pos_x = 0
  38.  
  39. while not isFull() do
  40.     autoRefuel()
  41.     while turtle.detect() do
  42.         turtle.dig()
  43.     end
  44.     turtle.forward()
  45.     pos_x = pos_x + 1
  46.     while turtle.detectUp() do
  47.         turtle.digUp()
  48.     end
  49. end
  50.  
  51. turtle.turnLeft()
  52. turtle.turnLeft()
  53.  
  54. while pos_x > 0 do
  55.     autoRefuel()
  56.     while turtle.detect() do
  57.         turtle.dig()
  58.     end
  59.     turtle.forward()
  60.     pos_x = pos_x - 1
  61.     while turtle.detectUp() do
  62.         turtle.digUp()
  63.     end
  64. end
  65.  
  66. turtle.turnLeft()
  67. turtle.turnLeft()
  68.  
  69. for i=1, 14 do
  70.     turtle.select(i)
  71.     turtle.dropDown()
  72. end
  73.  
Add Comment
Please, Sign In to add comment