Advertisement
BeepBeeps

Mine Test

Mar 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.83 KB | None | 0 0
  1. --Local
  2. local distance = 0 -- How Far Did User Pick
  3. local depth = 0
  4. local depthInput = 0
  5. local returnDepth = 0
  6. local ItemFuel = turtle.getItemCount(1) -- How many items are in slot 3 (Fuel)
  7. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  8. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  9. local Error = 0 -- 0 = No Error and 1 = Error
  10. local MD = 3 -- How Many Blocks Apart From Each Mine
  11. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  12. local Way = 0 -- 0 = Left and 1 = Right
  13.  
  14. --Checking
  15. local function Check()
  16.     if ItemFuel == 0 then
  17.         print("No Fuel Items")
  18.         error = 1
  19.     else
  20.         print("there is fuel")
  21.     end
  22.     repeat
  23.         if turtle.getFuelLevel() == "unlimited" then
  24.             print("NO NEED FOR FUEL")
  25.             Needfuel = 0
  26.         elseif turtle.getFuelLevel() < 100 then
  27.             turtle.select(1)
  28.             turtle.refuel(1)
  29.             Needfuel = 1
  30.             ItemFuel = ItemFuel - 1
  31.         elseif NeedFuel == 1 then
  32.             Needfuel = 0
  33.         end
  34.     until NeedFuel == 0
  35. end
  36.  
  37. -- Recheck if user forget something turtle will check after 15 sec
  38. local function Recheck()
  39.     ItemFuel = turtle.getItemCount(1)
  40.     Error = 0
  41. end
  42.  
  43. --Mining
  44. local function ForwardM()
  45.     repeat
  46.         if turtle.detect() then
  47.             turtle.dig()
  48.         end
  49.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  50.             TF = TF - 1
  51.         end
  52.         if turtle.detectUp() then
  53.             turtle.digUp()
  54.         end
  55.         repeat
  56.             if turtle.getFuelLevel() == "unlimited" then
  57.                 print("NO NEED FOR FUEL")
  58.                 Needfuel = 0
  59.             elseif turtle.getFuelLevel() < 100 then
  60.                 turtle.select(1)
  61.                 turtle.refuel(1)
  62.                 Needfuel = 1
  63.                 ItemFuel = ItemFuel - 1
  64.             elseif ItemFuel == 0 then
  65.                 print("turtle run out of fuel")
  66.                 os.shutdown()
  67.             elseif NeedFuel == 1 then
  68.                 Needfuel = 0
  69.             end
  70.         until NeedFuel == 0
  71.     until TF == 0
  72. end
  73.  
  74. -- Mine backwards
  75. local function Backwards() -- To make turn around so it can go back
  76.     turtle.turnLeft()
  77.     turtle.turnLeft()
  78.     turtle.digDown()
  79.     turtle.down()
  80.     turtle.digDown()
  81.     turtle.down()
  82. repeat
  83.         if turtle.detect() then
  84.             turtle.dig()
  85.         end
  86.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  87.             TB = TB - 1
  88.         end
  89.         if turtle.detectUp() then
  90.             turtle.digUp()
  91.         end
  92.         repeat
  93.             if turtle.getFuelLevel() == "unlimited" then
  94.                 print("NO NEED FOR FUEL")
  95.                 Needfuel = 0
  96.             elseif turtle.getFuelLevel() < 100 then
  97.                 turtle.select(1)
  98.                 turtle.refuel(1)
  99.                 Needfuel = 1
  100.                 ItemFuel = ItemFuel - 1
  101.             elseif ItemFuel == 0 then
  102.                 print("turtle run out of fuel")
  103.                 os.shutdown()
  104.             elseif NeedFuel == 1 then
  105.                 Needfuel = 0
  106.             end
  107.         until NeedFuel == 0
  108.     until TB == 0
  109.     turtle.turnRight()
  110.     turtle.turnRight()
  111.     turtle.digDown()
  112.     turtle.down()
  113.     turtle.digDown()
  114.     turtle.down()
  115. end
  116.  
  117. -- Multimines Program
  118. local function MultiMines()
  119.         if Way == 0 then
  120.                 turtle.turnLeft()
  121.         else
  122.                 turtle.turnRight()
  123.         end
  124.         repeat
  125.                 if turtle.detect() then
  126.                         turtle.dig()
  127.                 end
  128.                 if turtle.forward() then
  129.                         MD = MD - 1
  130.                 end
  131.                 if turtle.detectUp() then
  132.                         turtle.digUp()
  133.                 end
  134.         until MD == 0
  135.         if Way == 0 then
  136.                 turtle.turnLeft()
  137.                 if turtle.detect() then
  138.                     turtle.dig()
  139.                 end
  140.                 turtle.forward()
  141.                 turtle.turnRight()
  142.                 turtle.turnRight()
  143.         else
  144.                 turtle.turnRight()
  145.                 if turtle.detect() then
  146.                     turtle.dig()
  147.                 end
  148.                 turtle.forward()
  149.                 turtle.turnLeft()
  150.                 turtle.turnLeft()
  151.         end
  152.         if MineTimes == 0 then
  153.                 print("Turtle is done")
  154.         else
  155.                 MineTimes = MineTimes - 1
  156.         end
  157. end
  158.  
  159. -- Restart
  160. local function Restart()
  161.     TF = distance
  162.     TB = distance - 1
  163.     MD = 3
  164. end
  165.  
  166. -- Starting
  167. function Start()
  168.     repeat
  169.         repeat
  170.             depth = depth - 2
  171.                 ForwardM()
  172.                 Backwards()            
  173.                 Restart()
  174.         until depth <= 0
  175.         repeat
  176.             if turtle.detectUp() then
  177.                 turtle.digUp()
  178.             end
  179.             turtle.up()
  180.             returnDepth = returnDepth - 1
  181.         until returnDepth == 0
  182.         depth = depthInput
  183.         returnDepth = depthInput + 2
  184.         MultiMines()
  185.     until MineTimes == 0
  186. end
  187.  
  188. -- Start
  189. print("Hi There Welcome to Mining Turtle Program")
  190. print("How Far Will Turtle Go")
  191. input = io.read()
  192. distance = tonumber(input)
  193. TF = distance
  194. TB = distance - 1
  195. print("How Deep?")
  196. input1 = io.read()
  197. depthInput = tonumber(input1)
  198. depth = depthInput
  199. returnDepth = depthInput + 2
  200. print("Left or Right")
  201. print("0 = Left and 1 = Right")
  202. input2 = io.read()
  203. Way = tonumber(input2)
  204. print("How Many Times")
  205. input3 = io.read()
  206. MineTimes = tonumber(input3)
  207. Check()
  208. if Error == 1 then
  209.     repeat
  210.         sleep(10)
  211.         Recheck()
  212.         Check()
  213.     until Error == 0
  214. end
  215. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement