Pr1smZ

Tunnelfun2

Feb 5th, 2023 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | Gaming | 0 0
  1. function fuelLevel()
  2.  
  3.  if turtle.getFuelLevel() < 1000 then
  4.  
  5.   turtle.select(1)
  6.  
  7.   turtle.refuel(8)
  8.  
  9.   print("Refueled")
  10.  
  11.  else
  12.  
  13.   print("Enough Fuel")
  14.  
  15.  end
  16.  
  17. end
  18.  
  19.  
  20.  
  21. function mine()
  22.  
  23.  while turtle.detect() do
  24.  
  25.   turtle.dig()
  26.  
  27.   sleep(0.5)
  28.  
  29.  end
  30.  
  31.  turtle.forward()
  32.  
  33.  while turtle.detectUp() do
  34.  
  35.   turtle.digUp()
  36.  
  37.   sleep(0.5)
  38.  
  39.  end
  40.  
  41.  turtle.digDown()
  42.  
  43. end
  44.  
  45.  
  46.  
  47. function checkFull()
  48.  
  49.  if turtle.getItemCount(16) > 0 then
  50.  
  51.   turtle.back()
  52.  
  53.   turtle.down()
  54.  
  55.   turtle.digDown()
  56.  
  57.   turtle.select(3)
  58.  
  59.   turtle.placeDown()
  60.  
  61.   for i = 4,16 do
  62.  
  63.    turtle.select(i)
  64.  
  65.    turtle.dropDown()
  66.  
  67.   end
  68.  
  69.   turtle.select(2)
  70.  
  71.   turtle.up()
  72.  
  73.   turtle.forward()
  74.  
  75.  end
  76.  
  77. end
  78.  
  79.  
  80.  
  81. print("Place fuel in slot 1, torches in slot 2, and chests in slot 3!")
  82.  
  83. print("How wide will the tunnel be?")
  84.  
  85. local x = read()
  86.  
  87. print("How long will the tunnel be")
  88.  
  89. local y = read()
  90.  
  91.  
  92. turtle.select(2)
  93.  
  94. turtle.placeDown()
  95.  
  96. for i = 1, y do
  97.      
  98.   for i = 1,9 do
  99.  
  100.    turtle.select(2)
  101.  
  102.    fuelLevel()
  103.  
  104.    checkFull()
  105.  
  106.    mine()
  107.  
  108.    turtle.turnLeft()
  109.  
  110.    for i = 1,((x/2)-0.5) do
  111.  
  112.     mine()
  113.  
  114.    end
  115.  
  116.    turtle.turnLeft()
  117.  
  118.    turtle.turnLeft()
  119.  
  120.    for i = 1,(x-1) do
  121.  
  122.     mine()
  123.  
  124.    end
  125.  
  126.    turtle.turnLeft()
  127.  
  128.    turtle.turnLeft()
  129.  
  130.    for i = 1,((x/2)-0.5) do
  131.  
  132.     turtle.forward()
  133.  
  134.    end
  135.  
  136.    turtle.turnRight()
  137.  
  138.   end
  139.  end
  140.  
  141.  turtle.select(2)
  142.  
  143.  turtle.placeDown()
  144.  
  145.  
  146. print( "Returning to start..." )
  147. -- Return to where we started
  148. for i = 1, y do
  149.     turtle.back()
  150. end
Advertisement
Add Comment
Please, Sign In to add comment