demchrome

John Mining Strip Mining Turtle enderchest version

Jan 23rd, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.43 KB | None | 0 0
  1. -- This Version
  2. -- 3.00
  3.  
  4. --Local
  5. local Mines = 0 -- Multi Mines Yes Or No 1 = yes and 0 = no
  6. local distance = 0 -- How Far Did User Pick
  7. local onlight = 0 -- When to Place Torch
  8. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  9. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  10. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  11. local MDbackUp = 3 -- Keep MD
  12. local MD = 3 -- How Many Blocks Apart From Each Mine
  13. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  14. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  15. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  16. local Error = 0
  17.  
  18. --Checking
  19. function check()
  20.   if torch == 0 then
  21.     print("There are no torch's in Turtle")
  22.     Error = 1
  23.   else
  24.     print("There are torch's in turtle")
  25.   end
  26.   if chest == 0 then
  27.     print("there are no chests")
  28.     Error = 1
  29.   else
  30.     print("There are chest in turtle")
  31.   end
  32.   repeat
  33.     if turtle.getFuelLevel() == "unlimited" then
  34.        print("NO NEED FOR FUEL")
  35.        Needfuel = 0
  36.     elseif turtle.getFuelLevel() < 100 then
  37.        turtle.select(3)
  38.        turtle.refuel(1)
  39.        Needfuel = 1
  40.        ItemFuel = ItemFuel - 1
  41.     elseif NeedFuel == 1 then
  42.        Needfuel = 0
  43.     end
  44.   until NeedFuel == 0
  45.   if Error == 1 then
  46.     Test()
  47.   else
  48.     forwardM()
  49.   end
  50. end
  51.  
  52.  
  53. --Mining
  54. function forwardM()
  55.   repeat
  56.     if turtle.detect() then
  57.       turtle.dig()
  58.     end
  59.     if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  60.       TF = TF - 1
  61.       onlight = onlight + 1
  62.     end
  63.     if turtle.detectUp() then
  64.       turtle.digUp()
  65.     end
  66.     turtle.select(4)
  67.     turtle.placeDown()
  68.     if onlight == 10 then -- Every 10 Block turtle place torch
  69.       turtle.turnLeft()
  70.       turtle.turnLeft()
  71.       turtle.select(1)
  72.       turtle.place()
  73.       turtle.turnLeft()
  74.       turtle.turnLeft()
  75.       torch = torch - 1
  76.       onlight = onlight - 10
  77.     end
  78.     if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  79.       turtle.select(2)
  80.       turtle.digDown()
  81.       turtle.placeDown()
  82.       chest = chest - 1
  83.       for slot = 5, 16 do
  84.         turtle.select(slot)
  85.         turtle.dropDown()
  86.         sleep(0.5) -- Small fix for slow pc
  87.       end
  88.       turtle.select(2)
  89.       turtle.digDown()
  90.       turtle.select(5) -- temp fix still checking
  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(3)
  98.          turtle.refuel(1)
  99.          Needfuel = 1
  100.          ItemFuel = ItemFuel - 1
  101.       elseif NeedFuel == 1 then
  102.          Needfuel = 0
  103.       end
  104.     until NeedFuel == 0
  105.     until TF == 0
  106.     if TF == 0 then
  107.       backA()
  108.     end
  109. end
  110.  
  111. --Warm Up For Back Program
  112. function backA() -- To make turn around so it can go back
  113.   turtle.turnLeft()
  114.   turtle.turnLeft()
  115.   turtle.up()
  116.   back()
  117. end
  118.  
  119. --Back Program
  120. function back()
  121.   repeat
  122.     if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  123.       TB = TB - 1
  124.     end
  125.     if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  126.       turtle.dig()
  127.     end
  128.   until TB == 0
  129.   if Mines == 1 then
  130.     MultiMines()
  131.   else
  132.     print("Turtle done")
  133.   end
  134. end
  135.  
  136. -- Multimines Program
  137. function MultiMines()
  138.   turtle.turnRight()
  139.   turtle.down()
  140.   repeat
  141.     if turtle.detect() then
  142.       turtle.dig()
  143.     end
  144.     if turtle.forward() then
  145.       MD = MD - 1
  146.     end
  147.     if turtle.detectUp() then
  148.       turtle.digUp()
  149.     end
  150.   until MD == 0
  151.   turtle.turnRight()
  152.   if MineTimes == 0 then
  153.      print("Turtle is done")
  154.   else
  155.      MineTimes = MineTimes - 1
  156.      Restart()
  157.   end
  158. end
  159.  
  160. -- Restart
  161. function Restart()
  162.   TF = distance
  163.   TB = distance
  164.   MD = MDbackUp
  165.   onlight = 0
  166.   forwardM()
  167. end
  168.  
  169. -- Error
  170. function Test()
  171.   print("Pls Recheck And try aging")
  172. end
  173.  
  174. -- Start
  175. print("Hi There Welcome to Mining Turtle Program")
  176. print("How Far Will Turtle Go")
  177. input = io.read()
  178. distance = tonumber(input)
  179. TF = distance
  180. TB = distance
  181. print("To Want Multiple Strip Mines No = 0, Yes = 1")
  182. input2 = io.read()
  183. Mines = tonumber(input2)
  184. if Mines == 1 then
  185.   print("How Many Times")
  186.   input3 = io.read()
  187.   MineTimes = tonumber(input3)
  188.   check()
  189. else
  190.   check()
  191. end
Advertisement
Add Comment
Please, Sign In to add comment