Bonzai1102

mine adv

Jan 6th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. function fuel()
  2.     fuelLevel = turtle.getFuelLevel()
  3.         if fuelLevel == "unlimited" or fuelLevel > 10 then
  4.             return
  5.         end
  6.  
  7.     function tryRefuel()
  8.         for n=4,16 do
  9.             if turtle.getItemCount(n) > 0 then
  10.                 turtle.select(n)
  11.                 if turtle.refuel(1) then
  12.                     print("Fuel: "..turtle.getFuelLevel().."")
  13.                     turtle.select(2)
  14.                     return true
  15.                 end
  16.             end
  17.         end
  18.         turtle.select(2)
  19.         return false
  20.     end
  21.  
  22.     if not tryRefuel() then
  23.         print( "Add more fuel to continue." )
  24.             while not tryRefuel() do
  25.                 sleep(1)
  26.             end
  27.         print( "Resuming Tunnel." )
  28.     end
  29. end
  30.  
  31. function turn()
  32.     turtle.turnRight()
  33.     turtle.turnRight()
  34. end
  35.  
  36. function dig()
  37.     turtle.dig()
  38.     sleep(1)      
  39. end
  40.  
  41. function tunnel()
  42.     turtle.digUp()
  43.     turtle.select(2)
  44.     turtle.placeDown()
  45.     turtle.turnLeft()
  46.     turtle.detect()
  47.     turtle.place()
  48.     turtle.turnLeft()
  49.     turtle.turnLeft()
  50.     turtle.detect()
  51.     turtle.place()
  52.     turtle.turnLeft()
  53. end
  54.  
  55. function torch()
  56.     if distance == 10 then
  57.         turtle.select(2)
  58.             while turtle.up() == false do
  59.                 turtle.digUp()
  60.                 sleep(1)
  61.             end
  62.         turtle.turnLeft()
  63.         turtle.dig()
  64.         sleep(1)
  65.             while turtle.forward() == false do
  66.                 turtle.dig()
  67.                 sleep(1)
  68.             end
  69.         turtle.place()
  70.         turtle.placeUp()
  71.         turtle.back()
  72.         turtle.select(3)
  73.         turtle.place()
  74.         turtle.turnRight()
  75.         turtle.down()
  76.         distance = 0
  77.     end
  78. end
  79.  
  80. function chest()
  81.     for n = 5, 16 do
  82.         turtle.getItemCount()
  83.     end
  84.         if not turtle.getItemCount(n) == 0 then
  85.             turn()
  86.             turtle.select(1)
  87.             turtle.place()
  88.                 for n = 5, 16 do
  89.                     turtle.drop()
  90.                     sleep(1)
  91.                 end
  92.             turtle.dig()
  93.             turn()
  94.         end
  95. end
  96.  
  97. function back()
  98.     turtle.up()
  99.     turn()
  100.         while  j > 1 do
  101.             if turtle.forward() == true then
  102.                 fuel()
  103.                 j = j - 1
  104.             else
  105.                 dig()
  106.             end
  107.         end
  108.     turtle.down()
  109.     turn()
  110. end
  111.  
  112.     -- Main-Script --
  113. print("Slot 1: Enderchest")
  114. print("Slot 2: Cobblestone")
  115. print("Slot 3: Torch")
  116. print("Slot 4: Coal")
  117. print("Fuel: "..turtle.getFuelLevel().."")
  118. write("Tunnel length: ")
  119. length = tonumber(read())
  120. print("Starting...")
  121. i = 1
  122. j = 1
  123. distance = 1
  124.     while i <= length do
  125.         if turtle.forward() == true then
  126.             fuel()
  127.             chest()
  128.             tunnel()
  129.             torch()
  130.             i = i + 1
  131.             j = j + 1
  132.             distance = distance +1
  133.         else
  134.             dig()
  135.         end
  136.     end
  137. back()
  138. print("Done...")
Advertisement
Add Comment
Please, Sign In to add comment